@nmshd/connector-types 6.33.2 → 6.34.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/dist/infrastructure/httpServer/HttpServerRole.d.ts +6 -0
- package/dist/infrastructure/httpServer/HttpServerRole.d.ts.map +1 -0
- package/dist/infrastructure/httpServer/HttpServerRole.js +10 -0
- package/dist/infrastructure/httpServer/HttpServerRole.js.map +1 -0
- package/dist/infrastructure/httpServer/common/HttpErrors.d.ts +1 -0
- package/dist/infrastructure/httpServer/common/HttpErrors.d.ts.map +1 -1
- package/dist/infrastructure/httpServer/common/HttpErrors.js +3 -0
- package/dist/infrastructure/httpServer/common/HttpErrors.js.map +1 -1
- package/dist/infrastructure/httpServer/globals.d.ts +9 -0
- package/dist/infrastructure/httpServer/globals.d.ts.map +1 -0
- package/dist/infrastructure/httpServer/globals.js +3 -0
- package/dist/infrastructure/httpServer/globals.js.map +1 -0
- package/dist/infrastructure/httpServer/index.d.ts +3 -0
- package/dist/infrastructure/httpServer/index.d.ts.map +1 -1
- package/dist/infrastructure/httpServer/index.js +3 -0
- package/dist/infrastructure/httpServer/index.js.map +1 -1
- package/dist/infrastructure/httpServer/middlewares/index.d.ts +2 -0
- package/dist/infrastructure/httpServer/middlewares/index.d.ts.map +1 -0
- package/dist/infrastructure/httpServer/middlewares/index.js +18 -0
- package/dist/infrastructure/httpServer/middlewares/index.js.map +1 -0
- package/dist/infrastructure/httpServer/middlewares/routeRequiresRoles.d.ts +3 -0
- package/dist/infrastructure/httpServer/middlewares/routeRequiresRoles.d.ts.map +1 -0
- package/dist/infrastructure/httpServer/middlewares/routeRequiresRoles.js +18 -0
- package/dist/infrastructure/httpServer/middlewares/routeRequiresRoles.js.map +1 -0
- package/package.json +26 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpServerRole.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/httpServer/HttpServerRole.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc;IACtB,KAAK,UAAU;IACf,SAAS,cAAc;IACvB,UAAU,eAAe;CAC5B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpServerRole = void 0;
|
|
4
|
+
var HttpServerRole;
|
|
5
|
+
(function (HttpServerRole) {
|
|
6
|
+
HttpServerRole["ADMIN"] = "admin";
|
|
7
|
+
HttpServerRole["DEVELOPER"] = "developer";
|
|
8
|
+
HttpServerRole["MONITORING"] = "monitoring";
|
|
9
|
+
})(HttpServerRole || (exports.HttpServerRole = HttpServerRole = {}));
|
|
10
|
+
//# sourceMappingURL=HttpServerRole.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpServerRole.js","sourceRoot":"","sources":["../../../src/infrastructure/httpServer/HttpServerRole.ts"],"names":[],"mappings":";;;AAAA,IAAY,cAIX;AAJD,WAAY,cAAc;IACtB,iCAAe,CAAA;IACf,yCAAuB,CAAA;IACvB,2CAAyB,CAAA;AAC7B,CAAC,EAJW,cAAc,8BAAd,cAAc,QAIzB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HttpError } from "./HttpError";
|
|
2
2
|
export declare class HttpErrors {
|
|
3
3
|
static unauthorized(): HttpError;
|
|
4
|
+
static forbidden(): HttpError;
|
|
4
5
|
static invalidJsonInPayload(): HttpError;
|
|
5
6
|
static routeDoesNotExist(): HttpError;
|
|
6
7
|
static methodNotAllowed(): HttpError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpErrors.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/httpServer/common/HttpErrors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,qBAAa,UAAU;WACL,YAAY,IAAI,SAAS;WAIzB,oBAAoB,IAAI,SAAS;WAIjC,iBAAiB,IAAI,SAAS;WAI9B,gBAAgB,IAAI,SAAS;WAI7B,aAAa,IAAI,SAAS;CAM3C"}
|
|
1
|
+
{"version":3,"file":"HttpErrors.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/httpServer/common/HttpErrors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,qBAAa,UAAU;WACL,YAAY,IAAI,SAAS;WAIzB,SAAS,IAAI,SAAS;WAItB,oBAAoB,IAAI,SAAS;WAIjC,iBAAiB,IAAI,SAAS;WAI9B,gBAAgB,IAAI,SAAS;WAI7B,aAAa,IAAI,SAAS;CAM3C"}
|
|
@@ -6,6 +6,9 @@ class HttpErrors {
|
|
|
6
6
|
static unauthorized() {
|
|
7
7
|
return new HttpError_1.HttpError("error.connector.unauthorized", "Unauthorized.");
|
|
8
8
|
}
|
|
9
|
+
static forbidden() {
|
|
10
|
+
return new HttpError_1.HttpError("error.connector.forbidden", "You are not allowed to access this endpoint.");
|
|
11
|
+
}
|
|
9
12
|
static invalidJsonInPayload() {
|
|
10
13
|
return new HttpError_1.HttpError("error.connector.validation.invalidJsonInPayload", "The given payload is not a valid json object.");
|
|
11
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpErrors.js","sourceRoot":"","sources":["../../../../src/infrastructure/httpServer/common/HttpErrors.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAExC,MAAa,UAAU;IACZ,MAAM,CAAC,YAAY;QACtB,OAAO,IAAI,qBAAS,CAAC,8BAA8B,EAAE,eAAe,CAAC,CAAC;IAC1E,CAAC;IAEM,MAAM,CAAC,oBAAoB;QAC9B,OAAO,IAAI,qBAAS,CAAC,iDAAiD,EAAE,+CAA+C,CAAC,CAAC;IAC7H,CAAC;IAEM,MAAM,CAAC,iBAAiB;QAC3B,OAAO,IAAI,qBAAS,CAAC,wCAAwC,EAAE,qCAAqC,CAAC,CAAC;IAC1G,CAAC;IAEM,MAAM,CAAC,gBAAgB;QAC1B,OAAO,IAAI,qBAAS,CAAC,uCAAuC,EAAE,iEAAiE,CAAC,CAAC;IACrI,CAAC;IAEM,MAAM,CAAC,aAAa;QACvB,OAAO,IAAI,qBAAS,CAChB,oCAAoC,EACpC,kIAAkI,CACrI,CAAC;IACN,CAAC;CACJ;
|
|
1
|
+
{"version":3,"file":"HttpErrors.js","sourceRoot":"","sources":["../../../../src/infrastructure/httpServer/common/HttpErrors.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAExC,MAAa,UAAU;IACZ,MAAM,CAAC,YAAY;QACtB,OAAO,IAAI,qBAAS,CAAC,8BAA8B,EAAE,eAAe,CAAC,CAAC;IAC1E,CAAC;IAEM,MAAM,CAAC,SAAS;QACnB,OAAO,IAAI,qBAAS,CAAC,2BAA2B,EAAE,8CAA8C,CAAC,CAAC;IACtG,CAAC;IAEM,MAAM,CAAC,oBAAoB;QAC9B,OAAO,IAAI,qBAAS,CAAC,iDAAiD,EAAE,+CAA+C,CAAC,CAAC;IAC7H,CAAC;IAEM,MAAM,CAAC,iBAAiB;QAC3B,OAAO,IAAI,qBAAS,CAAC,wCAAwC,EAAE,qCAAqC,CAAC,CAAC;IAC1G,CAAC;IAEM,MAAM,CAAC,gBAAgB;QAC1B,OAAO,IAAI,qBAAS,CAAC,uCAAuC,EAAE,iEAAiE,CAAC,CAAC;IACrI,CAAC;IAEM,MAAM,CAAC,aAAa;QACvB,OAAO,IAAI,qBAAS,CAChB,oCAAoC,EACpC,kIAAkI,CACrI,CAAC;IACN,CAAC;CACJ;AA3BD,gCA2BC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/httpServer/globals.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,OAAO,CAAC;QACd,UAAU,OAAO;YACb,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;SACxB;KACJ;CACJ;AAED,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"globals.js","sourceRoot":"","sources":["../../../src/infrastructure/httpServer/globals.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/httpServer/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/httpServer/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
|
|
@@ -16,6 +16,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./BaseController"), exports);
|
|
18
18
|
__exportStar(require("./common"), exports);
|
|
19
|
+
__exportStar(require("./globals"), exports);
|
|
19
20
|
__exportStar(require("./HttpMethod"), exports);
|
|
21
|
+
__exportStar(require("./HttpServerRole"), exports);
|
|
20
22
|
__exportStar(require("./IHttpServer"), exports);
|
|
23
|
+
__exportStar(require("./middlewares"), exports);
|
|
21
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/infrastructure/httpServer/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,2CAAyB;AACzB,+CAA6B;AAC7B,gDAA8B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/infrastructure/httpServer/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,2CAAyB;AACzB,4CAA0B;AAC1B,+CAA6B;AAC7B,mDAAiC;AACjC,gDAA8B;AAC9B,gDAA8B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/httpServer/middlewares/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./routeRequiresRoles"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/infrastructure/httpServer/middlewares/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routeRequiresRoles.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/httpServer/middlewares/routeRequiresRoles.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,wBAAgB,kBAAkB,CAAC,GAAG,aAAa,EAAE,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,IAG9D,KAAK,OAAO,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,YAAY,KAAG,IAAI,CAUvF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.routeRequiresRoles = routeRequiresRoles;
|
|
4
|
+
const typescript_rest_1 = require("@nmshd/typescript-rest");
|
|
5
|
+
function routeRequiresRoles(...requiredRoles) {
|
|
6
|
+
if (requiredRoles.length === 0)
|
|
7
|
+
throw new Error("At least one role must be specified.");
|
|
8
|
+
return (req, _, next) => {
|
|
9
|
+
const userRoles = req.userRoles;
|
|
10
|
+
const hasRole = userRoles && Array.isArray(userRoles) && requiredRoles.some((role) => userRoles.includes(role));
|
|
11
|
+
if (!hasRole) {
|
|
12
|
+
next(new typescript_rest_1.Errors.ForbiddenError("You are not allowed to access this endpoint."));
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
next();
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=routeRequiresRoles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routeRequiresRoles.js","sourceRoot":"","sources":["../../../../src/infrastructure/httpServer/middlewares/routeRequiresRoles.ts"],"names":[],"mappings":";;AAGA,gDAaC;AAhBD,4DAAgD;AAGhD,SAAgB,kBAAkB,CAAC,GAAG,aAAoC;IACtE,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAExF,OAAO,CAAC,GAAoB,EAAE,CAAmB,EAAE,IAA0B,EAAQ,EAAE;QACnF,MAAM,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC;QAChC,MAAM,OAAO,GAAG,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QAChH,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,IAAI,CAAC,IAAI,wBAAM,CAAC,cAAc,CAAC,8CAA8C,CAAC,CAAC,CAAC;YAChF,OAAO;QACX,CAAC;QAED,IAAI,EAAE,CAAC;IACX,CAAC,CAAC;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -22,7 +22,30 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "tsc",
|
|
24
24
|
"build:ci": "tsc",
|
|
25
|
-
"build:watch": "tsc --watch"
|
|
25
|
+
"build:watch": "tsc --watch",
|
|
26
|
+
"test": "jest -i",
|
|
27
|
+
"test:ci": "npm run test",
|
|
28
|
+
"test:local": "npm run test"
|
|
29
|
+
},
|
|
30
|
+
"jest": {
|
|
31
|
+
"maxWorkers": 2,
|
|
32
|
+
"preset": "ts-jest",
|
|
33
|
+
"testEnvironment": "node",
|
|
34
|
+
"testPathIgnorePatterns": [
|
|
35
|
+
"/node_modules/"
|
|
36
|
+
],
|
|
37
|
+
"testTimeout": 60000,
|
|
38
|
+
"transform": {
|
|
39
|
+
"^.+\\.ts$": [
|
|
40
|
+
"ts-jest",
|
|
41
|
+
{
|
|
42
|
+
"tsconfig": "test/tsconfig.json"
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"qrcode": "^1.5.4"
|
|
26
49
|
},
|
|
27
50
|
"devDependencies": {
|
|
28
51
|
"@js-soft/logging-abstractions": "^1.0.1",
|
|
@@ -35,7 +58,7 @@
|
|
|
35
58
|
"peerDependencies": {
|
|
36
59
|
"@js-soft/docdb-access-abstractions": "^1.2.0",
|
|
37
60
|
"@js-soft/ts-utils": "^2.3.3",
|
|
38
|
-
"@nmshd/runtime": "^6.60.
|
|
61
|
+
"@nmshd/runtime": "^6.60.5",
|
|
39
62
|
"@nmshd/typescript-rest": "^3.1.5",
|
|
40
63
|
"express": "^5.1.0"
|
|
41
64
|
},
|
|
@@ -43,8 +66,5 @@
|
|
|
43
66
|
"access": "public",
|
|
44
67
|
"provenance": true
|
|
45
68
|
},
|
|
46
|
-
"
|
|
47
|
-
"qrcode": "^1.5.4"
|
|
48
|
-
},
|
|
49
|
-
"version": "6.33.2"
|
|
69
|
+
"version": "6.34.0"
|
|
50
70
|
}
|