@privateaim/server-http-kit 0.8.3 → 0.8.5
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/CHANGELOG.md +52 -0
- package/dist/constants.d.ts +5 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +15 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/middlewares/error.d.ts.map +1 -1
- package/dist/middlewares/error.js +38 -10
- package/dist/middlewares/error.js.map +1 -1
- package/dist/middlewares/force-logged-in.d.ts.map +1 -1
- package/dist/middlewares/force-logged-in.js +1 -5
- package/dist/middlewares/force-logged-in.js.map +1 -1
- package/dist/middlewares/rate-limit.d.ts.map +1 -1
- package/dist/middlewares/rate-limit.js +8 -12
- package/dist/middlewares/rate-limit.js.map +1 -1
- package/dist/request/identity-realm.d.ts +8 -0
- package/dist/request/identity-realm.d.ts.map +1 -0
- package/dist/request/identity-realm.js +21 -0
- package/dist/request/identity-realm.js.map +1 -0
- package/dist/request/identity.d.ts +7 -0
- package/dist/request/identity.d.ts.map +1 -0
- package/dist/request/identity.js +32 -0
- package/dist/request/identity.js.map +1 -0
- package/dist/request/index.d.ts +3 -0
- package/dist/request/index.d.ts.map +1 -1
- package/dist/request/index.js +3 -0
- package/dist/request/index.js.map +1 -1
- package/dist/request/permission/helper.d.ts +5 -0
- package/dist/request/permission/helper.d.ts.map +1 -0
- package/dist/request/permission/helper.js +23 -0
- package/dist/request/permission/helper.js.map +1 -0
- package/dist/request/permission/index.d.ts +3 -0
- package/dist/request/permission/index.d.ts.map +1 -0
- package/dist/{validation → request/permission}/index.js +2 -4
- package/dist/request/permission/index.js.map +1 -0
- package/dist/request/permission/module.d.ts +13 -0
- package/dist/request/permission/module.d.ts.map +1 -0
- package/dist/request/permission/module.js +47 -0
- package/dist/request/permission/module.js.map +1 -0
- package/dist/request/types.d.ts +11 -12
- package/dist/request/types.d.ts.map +1 -1
- package/dist/services/authup/middleware.js +3 -3
- package/dist/services/authup/middleware.js.map +1 -1
- package/dist/services/authup/permission-provider.d.ts +5 -0
- package/dist/services/authup/permission-provider.d.ts.map +1 -0
- package/dist/services/authup/permission-provider.js +20 -0
- package/dist/services/authup/permission-provider.js.map +1 -0
- package/dist/services/authup/utils.d.ts +2 -2
- package/dist/services/authup/utils.d.ts.map +1 -1
- package/dist/services/authup/utils.js +21 -33
- package/dist/services/authup/utils.js.map +1 -1
- package/package.json +16 -16
- package/{dist/validation/type.js → src/constants.ts} +6 -4
- package/src/index.ts +1 -1
- package/src/middlewares/error.ts +46 -12
- package/src/middlewares/force-logged-in.ts +2 -8
- package/src/middlewares/rate-limit.ts +11 -16
- package/src/request/identity-realm.ts +26 -0
- package/src/request/identity.ts +33 -0
- package/src/request/index.ts +3 -0
- package/src/request/permission/helper.ts +24 -0
- package/src/{validation → request/permission}/index.ts +2 -4
- package/src/request/permission/module.ts +60 -0
- package/src/request/types.ts +12 -10
- package/src/services/authup/middleware.ts +3 -3
- package/src/services/authup/permission-provider.ts +18 -0
- package/src/services/authup/utils.ts +27 -39
- package/dist/validation/index.d.ts +0 -5
- package/dist/validation/index.d.ts.map +0 -1
- package/dist/validation/index.js.map +0 -1
- package/dist/validation/message.d.ts +0 -2
- package/dist/validation/message.d.ts.map +0 -1
- package/dist/validation/message.js +0 -17
- package/dist/validation/message.js.map +0 -1
- package/dist/validation/module.d.ts +0 -6
- package/dist/validation/module.d.ts.map +0 -1
- package/dist/validation/module.js +0 -45
- package/dist/validation/module.js.map +0 -1
- package/dist/validation/result.d.ts +0 -7
- package/dist/validation/result.d.ts.map +0 -1
- package/dist/validation/result.js +0 -43
- package/dist/validation/result.js.map +0 -1
- package/dist/validation/type.d.ts +0 -15
- package/dist/validation/type.d.ts.map +0 -1
- package/dist/validation/type.js.map +0 -1
- package/src/validation/message.ts +0 -17
- package/src/validation/module.ts +0 -49
- package/src/validation/result.ts +0 -58
- package/src/validation/type.ts +0 -28
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.8.5](https://github.com/PrivateAIM/hub/compare/v0.8.4...v0.8.5) (2025-01-22)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* bump authup dependencies & adjusted code base ([90f7131](https://github.com/PrivateAIM/hub/commit/90f7131723e4e00dad04cb5ababa3e3f232e9c24))
|
|
9
|
+
* migrate to new http create validator syntax ([38ca70e](https://github.com/PrivateAIM/hub/commit/38ca70ee1b060a7d1bd22c87bddcdde21b6fbadc))
|
|
10
|
+
* refactor http controller validation ([#880](https://github.com/PrivateAIM/hub/issues/880)) ([6e11074](https://github.com/PrivateAIM/hub/commit/6e110742f946d4d0e827f4beb497ba2612568b9a))
|
|
11
|
+
* refactoring of master-image workflow ([#845](https://github.com/PrivateAIM/hub/issues/845)) ([7d2b866](https://github.com/PrivateAIM/hub/commit/7d2b8662b24dcf411d3ae8232152fecf53167382))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* **deps:** bump @authup/core-kit from 1.0.0-beta.22 to 1.0.0-beta.23 ([#896](https://github.com/PrivateAIM/hub/issues/896)) ([e0dcfed](https://github.com/PrivateAIM/hub/commit/e0dcfed47320bd53fadbca11a05ca677ed0ef7ff))
|
|
17
|
+
* **deps:** bump @authup/kit from 1.0.0-beta.22 to 1.0.0-beta.23 ([#901](https://github.com/PrivateAIM/hub/issues/901)) ([00a447c](https://github.com/PrivateAIM/hub/commit/00a447ce40ab17b67b0809b41c4233e424303a7c))
|
|
18
|
+
* **deps:** bump authup to v1.0.0-beta.24 ([#963](https://github.com/PrivateAIM/hub/issues/963)) ([90c40c0](https://github.com/PrivateAIM/hub/commit/90c40c0d55018557ee8bb381aad7e3cfbcd29b83))
|
|
19
|
+
* **deps:** bump the minorandpatch group across 1 directory with 31 updates ([#945](https://github.com/PrivateAIM/hub/issues/945)) ([448e9b8](https://github.com/PrivateAIM/hub/commit/448e9b86bf80f83c4aa8bb32ee0a75190a1d5cb8))
|
|
20
|
+
* fake permisison provider for test execution ([480a322](https://github.com/PrivateAIM/hub/commit/480a322595a67efb80809fd0d8319babcf49d63f))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Dependencies
|
|
24
|
+
|
|
25
|
+
* The following workspace dependencies were updated
|
|
26
|
+
* dependencies
|
|
27
|
+
* @privateaim/kit bumped from ^0.8.4 to ^0.8.5
|
|
28
|
+
* @privateaim/server-kit bumped from ^0.8.4 to ^0.8.5
|
|
29
|
+
|
|
30
|
+
## [0.8.4](https://github.com/PrivateAIM/hub/compare/v0.8.3...v0.8.4) (2024-10-24)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
* bump authup & implement async policy & permission evaluation ([#807](https://github.com/PrivateAIM/hub/issues/807)) ([d065562](https://github.com/PrivateAIM/hub/commit/d065562585076e26553ad5a39f4a5789f7e18f24))
|
|
36
|
+
* bump authup & vuecs packages + refactored navigation ([c4db8d5](https://github.com/PrivateAIM/hub/commit/c4db8d51588b3d701815e2ba2f9b80e594f3663f))
|
|
37
|
+
* handle permission-/policy-error in error middleware ([4b4fae4](https://github.com/PrivateAIM/hub/commit/4b4fae4fd048ddf9509af3d611a201484b0d4eaf))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Bug Fixes
|
|
41
|
+
|
|
42
|
+
* condition for exposing error via middleware ([e7a5fee](https://github.com/PrivateAIM/hub/commit/e7a5feec09eec7f63c91e13781b4abc19cb787f6))
|
|
43
|
+
* **deps:** bump locter from 2.1.1 to 2.1.2 ([#795](https://github.com/PrivateAIM/hub/issues/795)) ([fdb8cba](https://github.com/PrivateAIM/hub/commit/fdb8cba0c5a991a57ed9a26a324b9f2fed6caf5c))
|
|
44
|
+
* **deps:** bump locter from 2.1.2 to 2.1.4 ([#816](https://github.com/PrivateAIM/hub/issues/816)) ([0af403a](https://github.com/PrivateAIM/hub/commit/0af403a0eef7bca9c4f316e6598607c2897a8065))
|
|
45
|
+
* **deps:** bump typeorm-extension from 3.6.1 to 3.6.2 ([#810](https://github.com/PrivateAIM/hub/issues/810)) ([c9af9ae](https://github.com/PrivateAIM/hub/commit/c9af9aea537c4a51aae13f1059c1565180045a83))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Dependencies
|
|
49
|
+
|
|
50
|
+
* The following workspace dependencies were updated
|
|
51
|
+
* dependencies
|
|
52
|
+
* @privateaim/kit bumped from ^0.8.3 to ^0.8.4
|
|
53
|
+
* @privateaim/server-kit bumped from ^0.8.3 to ^0.8.4
|
|
54
|
+
|
|
3
55
|
## [0.8.3](https://github.com/PrivateAIM/hub/compare/v0.8.2...v0.8.3) (2024-09-19)
|
|
4
56
|
|
|
5
57
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAOA,oBAAY,oBAAoB;IAC5B,MAAM,WAAW;IACjB,MAAM,WAAW;CACpB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2024.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.HTTPHandlerOperation = void 0;
|
|
10
|
+
var HTTPHandlerOperation;
|
|
11
|
+
(function (HTTPHandlerOperation) {
|
|
12
|
+
HTTPHandlerOperation["CREATE"] = "create";
|
|
13
|
+
HTTPHandlerOperation["UPDATE"] = "update";
|
|
14
|
+
})(HTTPHandlerOperation || (exports.HTTPHandlerOperation = HTTPHandlerOperation = {}));
|
|
15
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC5B,yCAAiB,CAAA;IACjB,yCAAiB,CAAA;AACrB,CAAC,EAHW,oBAAoB,oCAApB,oBAAoB,QAG/B"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -20,9 +20,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
20
20
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
__exportStar(require("./constants"), exports);
|
|
23
24
|
__exportStar(require("./middlewares"), exports);
|
|
24
25
|
__exportStar(require("./request"), exports);
|
|
25
26
|
__exportStar(require("./services"), exports);
|
|
26
27
|
__exportStar(require("./swagger"), exports);
|
|
27
|
-
__exportStar(require("./validation"), exports);
|
|
28
28
|
//# 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;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,gDAA8B;AAC9B,4CAA0B;AAC1B,6CAA2B;AAC3B,4CAA0B
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,8CAA4B;AAC5B,gDAA8B;AAC9B,4CAA0B;AAC1B,6CAA2B;AAC3B,4CAA0B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/middlewares/error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/middlewares/error.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMrC,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,QAyElD"}
|
|
@@ -7,11 +7,44 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.mountErrorMiddleware = mountErrorMiddleware;
|
|
10
|
+
const access_1 = require("@authup/access");
|
|
10
11
|
const kit_1 = require("@privateaim/kit");
|
|
11
12
|
const routup_1 = require("routup");
|
|
12
13
|
const server_kit_1 = require("@privateaim/server-kit");
|
|
14
|
+
const typeorm_extension_1 = require("typeorm-extension");
|
|
15
|
+
const validup_1 = require("validup");
|
|
13
16
|
function mountErrorMiddleware(router) {
|
|
14
17
|
router.use((0, routup_1.errorHandler)((error, req, res) => {
|
|
18
|
+
const isServerError = error.statusCode >= 500 &&
|
|
19
|
+
error.statusCode < 600;
|
|
20
|
+
if (isServerError || error.logMessage) {
|
|
21
|
+
(0, server_kit_1.useLogger)().error(error);
|
|
22
|
+
if (error.cause) {
|
|
23
|
+
(0, server_kit_1.useLogger)().error(error.cause);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (error.cause instanceof access_1.PermissionError) {
|
|
27
|
+
error.expose = true;
|
|
28
|
+
if (error.cause.policy &&
|
|
29
|
+
error.cause.policy.type === access_1.BuiltInPolicyType.IDENTITY) {
|
|
30
|
+
error.statusCode = 401;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
error.statusCode = 403;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (error.cause instanceof typeorm_extension_1.EntityRelationLookupError) {
|
|
37
|
+
error.expose = true;
|
|
38
|
+
error.statusCode = 400;
|
|
39
|
+
}
|
|
40
|
+
if (error.cause instanceof validup_1.ValidupNestedError) {
|
|
41
|
+
error.expose = true;
|
|
42
|
+
error.statusCode = 400;
|
|
43
|
+
error.data = {
|
|
44
|
+
children: error.cause.children,
|
|
45
|
+
attributes: error.cause.children.map((child) => child.pathAbsolute),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
15
48
|
// catch and decorate some db errors :)
|
|
16
49
|
switch (error.code) {
|
|
17
50
|
case 'ER_DUP_ENTRY':
|
|
@@ -27,15 +60,10 @@ function mountErrorMiddleware(router) {
|
|
|
27
60
|
error.expose = true;
|
|
28
61
|
break;
|
|
29
62
|
}
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (error.cause) {
|
|
35
|
-
(0, server_kit_1.useLogger)().error(error.cause);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if (isServerError) {
|
|
63
|
+
const exposeError = typeof error.expose === 'boolean' ?
|
|
64
|
+
error.expose :
|
|
65
|
+
!isServerError;
|
|
66
|
+
if (!exposeError) {
|
|
39
67
|
error.message = 'An internal server error occurred.';
|
|
40
68
|
}
|
|
41
69
|
res.statusCode = error.statusCode;
|
|
@@ -43,7 +71,7 @@ function mountErrorMiddleware(router) {
|
|
|
43
71
|
statusCode: error.statusCode,
|
|
44
72
|
code: `${error.code}`,
|
|
45
73
|
message: error.message,
|
|
46
|
-
...((0, kit_1.isObject)(error.data)
|
|
74
|
+
...(exposeError && (0, kit_1.isObject)(error.data) ? error.data : {}),
|
|
47
75
|
};
|
|
48
76
|
}));
|
|
49
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/middlewares/error.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/middlewares/error.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"force-logged-in.d.ts","sourceRoot":"","sources":["../../src/middlewares/force-logged-in.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"force-logged-in.d.ts","sourceRoot":"","sources":["../../src/middlewares/force-logged-in.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EACR,IAAI,EAAE,OAAO,EAAE,QAAQ,EAC1B,MAAM,QAAQ,CAAC;AAGhB,qBAAa,uBAAwB,YAAW,gBAAgB;IACrD,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI;CAK9D"}
|
|
@@ -7,14 +7,10 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.ForceLoggedInMiddleware = void 0;
|
|
10
|
-
const http_1 = require("@ebec/http");
|
|
11
10
|
const request_1 = require("../request");
|
|
12
11
|
class ForceLoggedInMiddleware {
|
|
13
12
|
run(request, response, next) {
|
|
14
|
-
|
|
15
|
-
typeof (0, request_1.useRequestEnv)(request, 'robotId') === 'undefined') {
|
|
16
|
-
throw new http_1.UnauthorizedError();
|
|
17
|
-
}
|
|
13
|
+
(0, request_1.useRequestIdentityOrFail)(request);
|
|
18
14
|
next();
|
|
19
15
|
}
|
|
20
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"force-logged-in.js","sourceRoot":"","sources":["../../src/middlewares/force-logged-in.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;
|
|
1
|
+
{"version":3,"file":"force-logged-in.js","sourceRoot":"","sources":["../../src/middlewares/force-logged-in.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAMH,wCAAsD;AAEtD,MAAa,uBAAuB;IACzB,GAAG,CAAC,OAAgB,EAAE,QAAkB,EAAE,IAAU;QACvD,IAAA,kCAAwB,EAAC,OAAO,CAAC,CAAC;QAElC,IAAI,EAAE,CAAC;IACX,CAAC;CACJ;AAND,0DAMC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate-limit.d.ts","sourceRoot":"","sources":["../../src/middlewares/rate-limit.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAW,MAAM,EAAE,MAAM,QAAQ,CAAC;AAG9C,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"rate-limit.d.ts","sourceRoot":"","sources":["../../src/middlewares/rate-limit.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAW,MAAM,EAAE,MAAM,QAAQ,CAAC;AAG9C,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,QA4BxD"}
|
|
@@ -13,22 +13,18 @@ const request_1 = require("../request");
|
|
|
13
13
|
function mountRateLimiterMiddleware(router) {
|
|
14
14
|
const options = {
|
|
15
15
|
skip(req) {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
(0, request_1.useRequestEnv)(req, 'robotName') === 'system') {
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return false;
|
|
16
|
+
const identity = (0, request_1.useRequestIdentity)(req);
|
|
17
|
+
return identity &&
|
|
18
|
+
identity.type === 'robot' &&
|
|
19
|
+
identity.realmName === core_kit_1.REALM_MASTER_NAME;
|
|
25
20
|
},
|
|
26
21
|
max(req) {
|
|
27
|
-
|
|
22
|
+
const identity = (0, request_1.useRequestIdentity)(req);
|
|
23
|
+
if (identity && identity.type === 'user') {
|
|
28
24
|
return 60 * 100; // 100 req p. sec
|
|
29
25
|
}
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
if (identity &&
|
|
27
|
+
(identity.type === 'robot' || identity.type === 'client')) {
|
|
32
28
|
return 60 * 1000; // 1000 req p. sec
|
|
33
29
|
}
|
|
34
30
|
return 60 * 20; // 20 req p. sec
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate-limit.js","sourceRoot":"","sources":["../../src/middlewares/rate-limit.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAQH,
|
|
1
|
+
{"version":3,"file":"rate-limit.js","sourceRoot":"","sources":["../../src/middlewares/rate-limit.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAQH,gEA4BC;AAlCD,+CAAqD;AAErD,mDAA+C;AAE/C,wCAAgD;AAEhD,SAAgB,0BAA0B,CAAC,MAAc;IACrD,MAAM,OAAO,GAAkB;QAC3B,IAAI,CAAC,GAAY;YACb,MAAM,QAAQ,GAAG,IAAA,4BAAkB,EAAC,GAAG,CAAC,CAAC;YAEzC,OAAO,QAAQ;gBACX,QAAQ,CAAC,IAAI,KAAK,OAAO;gBACzB,QAAQ,CAAC,SAAS,KAAK,4BAAiB,CAAC;QACjD,CAAC;QACD,GAAG,CAAC,GAAY;YACZ,MAAM,QAAQ,GAAG,IAAA,4BAAkB,EAAC,GAAG,CAAC,CAAC;YACzC,IAAI,QAAQ,IAAI,QAAQ,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBACvC,OAAO,EAAE,GAAG,GAAG,CAAC,CAAC,iBAAiB;YACtC,CAAC;YAED,IACI,QAAQ;gBACR,CAAC,QAAQ,CAAC,IAAI,KAAK,OAAO,IAAI,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,EAC3D,CAAC;gBACC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC,kBAAkB;YACxC,CAAC;YAED,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,gBAAgB;QACpC,CAAC;QACD,QAAQ,EAAE,EAAE,GAAG,IAAI,EAAE,SAAS;KACjC,CAAC;IAEF,MAAM,CAAC,GAAG,CAAC,IAAA,sBAAS,EAAC,OAAO,CAAC,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-realm.d.ts","sourceRoot":"","sources":["../../src/request/identity-realm.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAGtC,KAAK,YAAY,GAAG;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAA;CACf,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,GAAI,YAAY,CAUnE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2024.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.useRequestIdentityRealm = useRequestIdentityRealm;
|
|
10
|
+
const identity_1 = require("./identity");
|
|
11
|
+
function useRequestIdentityRealm(req) {
|
|
12
|
+
const identity = (0, identity_1.useRequestIdentity)(req);
|
|
13
|
+
if (!identity) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
id: identity.realmId,
|
|
18
|
+
name: identity.realmName,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=identity-realm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-realm.js","sourceRoot":"","sources":["../../src/request/identity-realm.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAUH,0DAUC;AAjBD,yCAAgD;AAOhD,SAAgB,uBAAuB,CAAC,GAAY;IAChD,MAAM,QAAQ,GAAG,IAAA,6BAAkB,EAAC,GAAG,CAAC,CAAC;IACzC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACZ,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,OAAO;QACH,EAAE,EAAE,QAAQ,CAAC,OAAO;QACpB,IAAI,EAAE,QAAQ,CAAC,SAAS;KAC3B,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Request } from 'routup';
|
|
2
|
+
import type { RequestIdentity } from './types';
|
|
3
|
+
export declare function useRequestIdentity(req: Request): RequestIdentity | undefined;
|
|
4
|
+
export declare function setRequestIdentity(req: Request, identity: RequestIdentity): void;
|
|
5
|
+
export declare function useRequestIdentityOrFail(req: Request): RequestIdentity;
|
|
6
|
+
export declare function isRequestIdentityMasterRealmMember(input: RequestIdentity): boolean;
|
|
7
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/request/identity.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/C,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAI,eAAe,GAAG,SAAS,CAE7E;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,GAAI,IAAI,CAEjF;AAED,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAI,eAAe,CAOvE;AAED,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,eAAe,GAAI,OAAO,CAEnF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2024.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.useRequestIdentity = useRequestIdentity;
|
|
10
|
+
exports.setRequestIdentity = setRequestIdentity;
|
|
11
|
+
exports.useRequestIdentityOrFail = useRequestIdentityOrFail;
|
|
12
|
+
exports.isRequestIdentityMasterRealmMember = isRequestIdentityMasterRealmMember;
|
|
13
|
+
const core_kit_1 = require("@authup/core-kit");
|
|
14
|
+
const http_1 = require("@ebec/http");
|
|
15
|
+
const env_1 = require("./env");
|
|
16
|
+
function useRequestIdentity(req) {
|
|
17
|
+
return (0, env_1.useRequestEnv)(req, 'identity');
|
|
18
|
+
}
|
|
19
|
+
function setRequestIdentity(req, identity) {
|
|
20
|
+
(0, env_1.setRequestEnv)(req, 'identity', identity);
|
|
21
|
+
}
|
|
22
|
+
function useRequestIdentityOrFail(req) {
|
|
23
|
+
const identity = useRequestIdentity(req);
|
|
24
|
+
if (!identity) {
|
|
25
|
+
throw new http_1.UnauthorizedError();
|
|
26
|
+
}
|
|
27
|
+
return identity;
|
|
28
|
+
}
|
|
29
|
+
function isRequestIdentityMasterRealmMember(input) {
|
|
30
|
+
return input.realmName === core_kit_1.REALM_MASTER_NAME;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/request/identity.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAQH,gDAEC;AAED,gDAEC;AAED,4DAOC;AAED,gFAEC;AAzBD,+CAAqD;AACrD,qCAA+C;AAG/C,+BAAqD;AAErD,SAAgB,kBAAkB,CAAC,GAAY;IAC3C,OAAO,IAAA,mBAAa,EAAC,GAAG,EAAE,UAAU,CAAC,CAAC;AAC1C,CAAC;AAED,SAAgB,kBAAkB,CAAC,GAAY,EAAE,QAAyB;IACtE,IAAA,mBAAa,EAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC7C,CAAC;AAED,SAAgB,wBAAwB,CAAC,GAAY;IACjD,MAAM,QAAQ,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACZ,MAAM,IAAI,wBAAiB,EAAE,CAAC;IAClC,CAAC;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC;AAED,SAAgB,kCAAkC,CAAC,KAAsB;IACrE,OAAO,KAAK,CAAC,SAAS,KAAK,4BAAiB,CAAC;AACjD,CAAC"}
|
package/dist/request/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/request/index.ts"],"names":[],"mappings":"AAOA,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/request/index.ts"],"names":[],"mappings":"AAOA,cAAc,cAAc,CAAC;AAC7B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC"}
|
package/dist/request/index.js
CHANGED
|
@@ -20,6 +20,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
20
20
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
__exportStar(require("./permission"), exports);
|
|
23
24
|
__exportStar(require("./env"), exports);
|
|
25
|
+
__exportStar(require("./identity"), exports);
|
|
26
|
+
__exportStar(require("./identity-realm"), exports);
|
|
24
27
|
__exportStar(require("./types"), exports);
|
|
25
28
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/request/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,wCAAsB;AACtB,0CAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/request/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,+CAA6B;AAC7B,wCAAsB;AACtB,6CAA2B;AAC3B,mDAAiC;AACjC,0CAAwB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Request } from 'routup';
|
|
2
|
+
import type { RequestPermissionChecker } from './module';
|
|
3
|
+
export declare function setRequestPermissionChecker(req: Request, checker: RequestPermissionChecker): void;
|
|
4
|
+
export declare function useRequestPermissionChecker(req: Request): RequestPermissionChecker;
|
|
5
|
+
//# sourceMappingURL=helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../../src/request/permission/helper.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAEzD,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,wBAAwB,QAE1F;AAED,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,OAAO,GAAI,wBAAwB,CAOnF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2024.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.setRequestPermissionChecker = setRequestPermissionChecker;
|
|
10
|
+
exports.useRequestPermissionChecker = useRequestPermissionChecker;
|
|
11
|
+
const http_1 = require("@ebec/http");
|
|
12
|
+
const env_1 = require("../env");
|
|
13
|
+
function setRequestPermissionChecker(req, checker) {
|
|
14
|
+
(0, env_1.setRequestEnv)(req, 'permissionChecker', checker);
|
|
15
|
+
}
|
|
16
|
+
function useRequestPermissionChecker(req) {
|
|
17
|
+
const checker = (0, env_1.useRequestEnv)(req, 'permissionChecker');
|
|
18
|
+
if (!checker) {
|
|
19
|
+
throw new http_1.BadRequestError('The request permission checker is not initialized.');
|
|
20
|
+
}
|
|
21
|
+
return checker;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../src/request/permission/helper.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAOH,kEAEC;AAED,kEAOC;AAfD,qCAA6C;AAC7C,gCAAsD;AAGtD,SAAgB,2BAA2B,CAAC,GAAY,EAAE,OAAiC;IACvF,IAAA,mBAAa,EAAC,GAAG,EAAE,mBAAmB,EAAE,OAAO,CAAC,CAAC;AACrD,CAAC;AAED,SAAgB,2BAA2B,CAAC,GAAY;IACpD,MAAM,OAAO,GAAG,IAAA,mBAAa,EAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC;IACxD,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,MAAM,IAAI,sBAAe,CAAC,oDAAoD,CAAC,CAAC;IACpF,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/request/permission/index.ts"],"names":[],"mappings":"AAOA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2024.
|
|
4
4
|
* Author Peter Placzek (tada5hi)
|
|
5
5
|
* For the full copyright and license information,
|
|
6
6
|
* view the LICENSE file that was distributed with this source code.
|
|
@@ -20,8 +20,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
20
20
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
__exportStar(require("./
|
|
23
|
+
__exportStar(require("./helper"), exports);
|
|
24
24
|
__exportStar(require("./module"), exports);
|
|
25
|
-
__exportStar(require("./type"), exports);
|
|
26
|
-
__exportStar(require("./result"), exports);
|
|
27
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/request/permission/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,2CAAyB;AACzB,2CAAyB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PermissionChecker, PermissionCheckerCheckContext } from '@authup/access';
|
|
2
|
+
import type { Request } from 'routup';
|
|
3
|
+
export declare class RequestPermissionChecker {
|
|
4
|
+
protected req: Request;
|
|
5
|
+
protected checker: PermissionChecker;
|
|
6
|
+
constructor(req: Request, checker: PermissionChecker);
|
|
7
|
+
check(ctx: PermissionCheckerCheckContext): Promise<void>;
|
|
8
|
+
preCheck(ctx: PermissionCheckerCheckContext): Promise<void>;
|
|
9
|
+
preCheckOneOf(ctx: PermissionCheckerCheckContext): Promise<void>;
|
|
10
|
+
checkOneOf(ctx: PermissionCheckerCheckContext): Promise<void>;
|
|
11
|
+
protected extendCheckContext(ctx: PermissionCheckerCheckContext): PermissionCheckerCheckContext;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/request/permission/module.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACR,iBAAiB,EACjB,6BAA6B,EAChC,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAItC,qBAAa,wBAAwB;IACjC,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC;IAEvB,SAAS,CAAC,OAAO,EAAE,iBAAiB,CAAC;gBAEzB,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB;IAO9C,KAAK,CAAC,GAAG,EAAE,6BAA6B,GAAI,OAAO,CAAC,IAAI,CAAC;IAIzD,QAAQ,CAAC,GAAG,EAAE,6BAA6B,GAAI,OAAO,CAAC,IAAI,CAAC;IAM5D,aAAa,CAAC,GAAG,EAAE,6BAA6B,GAAI,OAAO,CAAC,IAAI,CAAC;IAIjE,UAAU,CAAC,GAAG,EAAE,6BAA6B,GAAI,OAAO,CAAC,IAAI,CAAC;IAMpE,SAAS,CAAC,kBAAkB,CAAC,GAAG,EAAE,6BAA6B;CAWlE"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2024.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.RequestPermissionChecker = void 0;
|
|
10
|
+
const core_kit_1 = require("@authup/core-kit");
|
|
11
|
+
const env_1 = require("../env");
|
|
12
|
+
const identity_1 = require("../identity");
|
|
13
|
+
class RequestPermissionChecker {
|
|
14
|
+
req;
|
|
15
|
+
checker;
|
|
16
|
+
constructor(req, checker) {
|
|
17
|
+
this.req = req;
|
|
18
|
+
this.checker = checker;
|
|
19
|
+
}
|
|
20
|
+
// --------------------------------------------------------------
|
|
21
|
+
async check(ctx) {
|
|
22
|
+
return this.checker.check(this.extendCheckContext(ctx));
|
|
23
|
+
}
|
|
24
|
+
async preCheck(ctx) {
|
|
25
|
+
return this.checker.preCheck(this.extendCheckContext(ctx));
|
|
26
|
+
}
|
|
27
|
+
// --------------------------------------------------------------
|
|
28
|
+
async preCheckOneOf(ctx) {
|
|
29
|
+
return this.checker.preCheckOneOf(this.extendCheckContext(ctx));
|
|
30
|
+
}
|
|
31
|
+
async checkOneOf(ctx) {
|
|
32
|
+
return this.checker.checkOneOf(this.extendCheckContext(ctx));
|
|
33
|
+
}
|
|
34
|
+
// --------------------------------------------------------------
|
|
35
|
+
extendCheckContext(ctx) {
|
|
36
|
+
const scopes = (0, env_1.useRequestEnv)(this.req, 'scopes') || [];
|
|
37
|
+
if (scopes.indexOf(core_kit_1.ScopeName.GLOBAL) !== -1) {
|
|
38
|
+
ctx.data = {
|
|
39
|
+
...ctx.data || {},
|
|
40
|
+
identity: (0, identity_1.useRequestIdentity)(this.req),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return ctx;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.RequestPermissionChecker = RequestPermissionChecker;
|
|
47
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../../src/request/permission/module.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+CAA6C;AAM7C,gCAAuC;AACvC,0CAAiD;AAEjD,MAAa,wBAAwB;IACvB,GAAG,CAAU;IAEb,OAAO,CAAoB;IAErC,YAAY,GAAY,EAAE,OAA0B;QAChD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED,iEAAiE;IAEjE,KAAK,CAAC,KAAK,CAAC,GAAkC;QAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,GAAkC;QAC7C,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,iEAAiE;IAEjE,KAAK,CAAC,aAAa,CAAC,GAAkC;QAClD,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC;IACpE,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,GAAkC;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC;IACjE,CAAC;IAED,iEAAiE;IAEvD,kBAAkB,CAAC,GAAkC;QAC3D,MAAM,MAAM,GAAG,IAAA,mBAAa,EAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;QACvD,IAAI,MAAM,CAAC,OAAO,CAAC,oBAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YAC1C,GAAG,CAAC,IAAI,GAAG;gBACP,GAAG,GAAG,CAAC,IAAI,IAAI,EAAE;gBACjB,QAAQ,EAAE,IAAA,6BAAkB,EAAC,IAAI,CAAC,GAAG,CAAC;aACzC,CAAC;QACN,CAAC;QAED,OAAO,GAAG,CAAC;IACf,CAAC;CACJ;AA3CD,4DA2CC"}
|
package/dist/request/types.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RequestPermissionChecker } from './permission';
|
|
2
|
+
export type RequestIdentity = {
|
|
3
|
+
id: string;
|
|
4
|
+
type: 'user' | 'client' | 'robot';
|
|
5
|
+
realmId: string;
|
|
6
|
+
realmName: string;
|
|
7
|
+
attributes?: Record<string, any>;
|
|
8
|
+
};
|
|
2
9
|
export type RequestEnv = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
realm?: {
|
|
7
|
-
id?: string;
|
|
8
|
-
name?: string;
|
|
9
|
-
};
|
|
10
|
-
userId?: string;
|
|
11
|
-
userName?: string;
|
|
12
|
-
robotId?: string;
|
|
13
|
-
robotName?: string;
|
|
10
|
+
permissionChecker?: RequestPermissionChecker;
|
|
11
|
+
identity?: RequestIdentity;
|
|
12
|
+
scopes?: string[];
|
|
14
13
|
};
|
|
15
14
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/request/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/request/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAE7D,MAAM,MAAM,eAAe,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACrB,iBAAiB,CAAC,EAAE,wBAAwB,CAAC;IAE7C,QAAQ,CAAC,EAAE,eAAe,CAAC;IAE3B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.mountAuthupMiddleware = mountAuthupMiddleware;
|
|
10
|
-
const
|
|
10
|
+
const server_adapter_http_1 = require("@authup/server-adapter-http");
|
|
11
11
|
const cookie_1 = require("@routup/basic/cookie");
|
|
12
12
|
const hapic_1 = require("hapic");
|
|
13
13
|
const routup_1 = require("routup");
|
|
@@ -37,7 +37,7 @@ function mountAuthupMiddleware(router, options) {
|
|
|
37
37
|
}
|
|
38
38
|
const header = (0, hapic_1.parseAuthorizationHeader)(headerRaw);
|
|
39
39
|
if (header.type === 'Basic') {
|
|
40
|
-
const token = await options.client.token.
|
|
40
|
+
const token = await options.client.token.createWithPassword({
|
|
41
41
|
username: header.username,
|
|
42
42
|
password: header.password,
|
|
43
43
|
});
|
|
@@ -72,7 +72,7 @@ function mountAuthupMiddleware(router, options) {
|
|
|
72
72
|
client: options.redisClient,
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
const middleware = (0,
|
|
75
|
+
const middleware = (0, server_adapter_http_1.createMiddleware)({
|
|
76
76
|
tokenByCookie: (req, cookieName) => (0, cookie_1.useRequestCookie)(req, cookieName),
|
|
77
77
|
tokenVerifier: {
|
|
78
78
|
baseURL: options.client.getBaseURL(),
|