@decaf-ts/for-nest 0.2.11 → 0.2.13
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/README.md +1 -1
- package/dist/for-nest.cjs +1 -1
- package/dist/for-nest.cjs.map +1 -1
- package/dist/for-nest.js +1 -1
- package/dist/for-nest.js.map +1 -1
- package/lib/constants.cjs +1 -2
- package/lib/constants.d.ts +0 -1
- package/lib/constants.js.map +1 -1
- package/lib/decaf-model/decorators/decorators.cjs +0 -22
- package/lib/decaf-model/decorators/decorators.d.ts +0 -17
- package/lib/decaf-model/decorators/decorators.js.map +1 -1
- package/lib/decaf-model/decorators/index.cjs +0 -1
- package/lib/decaf-model/decorators/index.d.ts +0 -1
- package/lib/decaf-model/decorators/index.js.map +1 -1
- package/lib/decoration.cjs +2 -0
- package/lib/decoration.js.map +1 -1
- package/lib/esm/constants.d.ts +0 -1
- package/lib/esm/constants.js +0 -1
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/decaf-model/decorators/decorators.d.ts +0 -17
- package/lib/esm/decaf-model/decorators/decorators.js +1 -21
- package/lib/esm/decaf-model/decorators/decorators.js.map +1 -1
- package/lib/esm/decaf-model/decorators/index.d.ts +0 -1
- package/lib/esm/decaf-model/decorators/index.js +0 -1
- package/lib/esm/decaf-model/decorators/index.js.map +1 -1
- package/lib/esm/decoration.js +2 -0
- package/lib/esm/decoration.js.map +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/request/DecafAuthHandler.js +3 -4
- package/lib/esm/request/DecafAuthHandler.js.map +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/request/DecafAuthHandler.cjs +2 -3
- package/lib/request/DecafAuthHandler.js.map +1 -1
- package/package.json +1 -1
- package/lib/decaf-model/decorators/route.cjs +0 -25
- package/lib/decaf-model/decorators/route.d.ts +0 -2
- package/lib/decaf-model/decorators/route.js.map +0 -1
- package/lib/esm/decaf-model/decorators/route.d.ts +0 -2
- package/lib/esm/decaf-model/decorators/route.js +0 -22
- package/lib/esm/decaf-model/decorators/route.js.map +0 -1
|
@@ -4,7 +4,6 @@ exports.DecafRoleAuthHandler = exports.DecafAuthHandler = void 0;
|
|
|
4
4
|
const decoration_1 = require("@decaf-ts/decoration");
|
|
5
5
|
const core_1 = require("@decaf-ts/core");
|
|
6
6
|
const decorator_validation_1 = require("@decaf-ts/decorator-validation");
|
|
7
|
-
const constants_1 = require("./../constants.cjs");
|
|
8
7
|
class DecafAuthHandler {
|
|
9
8
|
parseRequest(req) {
|
|
10
9
|
const userRole = req.headers.authorization?.split(" ")[1];
|
|
@@ -15,7 +14,7 @@ class DecafAuthHandler {
|
|
|
15
14
|
const userRole = this.parseRequest(req);
|
|
16
15
|
if (!userRole)
|
|
17
16
|
throw new core_1.AuthorizationError("Unauthenticated");
|
|
18
|
-
const roles = decoration_1.Metadata.get(decorator_validation_1.Model.get(resource),
|
|
17
|
+
const roles = decoration_1.Metadata.get(decorator_validation_1.Model.get(resource), core_1.PersistenceKeys.AUTH_ROLE);
|
|
19
18
|
if (!roles.includes(userRole)) {
|
|
20
19
|
throw new core_1.AuthorizationError(`Missing role: ${userRole}`);
|
|
21
20
|
}
|
|
@@ -31,7 +30,7 @@ class DecafRoleAuthHandler extends DecafAuthHandler {
|
|
|
31
30
|
const userRole = this.parseRequest(req);
|
|
32
31
|
if (!userRole)
|
|
33
32
|
throw new core_1.AuthorizationError("Unauthenticated");
|
|
34
|
-
const roles = decoration_1.Metadata.get(decorator_validation_1.Model.get(resource),
|
|
33
|
+
const roles = decoration_1.Metadata.get(decorator_validation_1.Model.get(resource), core_1.PersistenceKeys.AUTH_ROLE);
|
|
35
34
|
if (!roles.includes(userRole)) {
|
|
36
35
|
throw new core_1.AuthorizationError(`Missing role: ${userRole}`);
|
|
37
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecafAuthHandler.js","sourceRoot":"","sources":["../../src/request/DecafAuthHandler.ts"],"names":[],"mappings":";;;AACA,qDAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"DecafAuthHandler.js","sourceRoot":"","sources":["../../src/request/DecafAuthHandler.ts"],"names":[],"mappings":";;;AACA,qDAAgD;AAChD,yCAAqE;AACrE,yEAAuD;AAGvD,MAAa,gBAAgB;IACjB,YAAY,CAAC,GAAQ;QAC7B,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAW,CAAC;QACpE,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,GAAqB,EAAE,QAAgB;QACrD,MAAM,GAAG,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QAE5C,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QACxC,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,yBAAkB,CAAC,iBAAiB,CAAC,CAAC;QAE/D,MAAM,KAAK,GAAG,qBAAQ,CAAC,GAAG,CAAC,4BAAK,CAAC,GAAG,CAAC,QAAQ,CAAE,EAAE,sBAAe,CAAC,SAAS,CAAC,CAAC;QAE5E,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,yBAAkB,CAAC,iBAAiB,QAAQ,EAAE,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;CACF;AAlBD,4CAkBC;AAED,MAAa,oBAAqB,SAAQ,gBAAgB;IACxD;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAEQ,KAAK,CAAC,SAAS,CAAC,GAAqB,EAAE,QAAgB;QAC9D,MAAM,GAAG,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QAE5C,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QACxC,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,yBAAkB,CAAC,iBAAiB,CAAC,CAAC;QAE/D,MAAM,KAAK,GAAG,qBAAQ,CAAC,GAAG,CAAC,4BAAK,CAAC,GAAG,CAAC,QAAQ,CAAE,EAAE,sBAAe,CAAC,SAAS,CAAC,CAAC;QAE5E,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,yBAAkB,CAAC,iBAAiB,QAAQ,EAAE,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAlBD,oDAkBC"}
|
package/package.json
CHANGED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.route = route;
|
|
4
|
-
const decoration_1 = require("@decaf-ts/decoration");
|
|
5
|
-
const constants_1 = require("./../../constants.cjs");
|
|
6
|
-
function route(httpMethod, path) {
|
|
7
|
-
const key = constants_1.DECAF_ROUTE;
|
|
8
|
-
function route() {
|
|
9
|
-
return function route(obj, prop, descriptor) {
|
|
10
|
-
const options = {
|
|
11
|
-
path: path,
|
|
12
|
-
httpMethod: httpMethod,
|
|
13
|
-
handler: descriptor,
|
|
14
|
-
};
|
|
15
|
-
return (0, decoration_1.apply)((0, decoration_1.methodMetadata)(decoration_1.Metadata.key(key, prop), options))(obj, prop, descriptor);
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
return decoration_1.Decoration.for(key)
|
|
19
|
-
.define({
|
|
20
|
-
decorator: route,
|
|
21
|
-
args: [],
|
|
22
|
-
})
|
|
23
|
-
.apply();
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=route.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../src/decaf-model/decorators/route.ts"],"names":[],"mappings":";;AAUA,sBAwBC;AAlCD,qDAK8B;AAC9B,qDAA8C;AAI9C,SAAgB,KAAK,CAAC,UAAqB,EAAE,IAAY;IACvD,MAAM,GAAG,GAAG,uBAAW,CAAC;IACxB,SAAS,KAAK;QACZ,OAAO,SAAS,KAAK,CAAC,GAAW,EAAE,IAAU,EAAE,UAAgB;YAC7D,MAAM,OAAO,GAAyB;gBACpC,IAAI,EAAE,IAAI;gBACV,UAAU,EAAE,UAAU;gBACtB,OAAO,EAAE,UAAU;aACpB,CAAC;YAEF,OAAO,IAAA,kBAAK,EAAC,IAAA,2BAAc,EAAC,qBAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,CAC5D,GAAG,EACH,IAAI,EACJ,UAAU,CACX,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,uBAAU,CAAC,GAAG,CAAC,GAAG,CAAC;SACvB,MAAM,CAAC;QACN,SAAS,EAAE,KAAK;QAChB,IAAI,EAAE,EAAE;KACT,CAAC;SACD,KAAK,EAAE,CAAC;AACb,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { apply, Decoration, Metadata, methodMetadata, } from "@decaf-ts/decoration";
|
|
2
|
-
import { DECAF_ROUTE } from "./../../constants.js";
|
|
3
|
-
export function route(httpMethod, path) {
|
|
4
|
-
const key = DECAF_ROUTE;
|
|
5
|
-
function route() {
|
|
6
|
-
return function route(obj, prop, descriptor) {
|
|
7
|
-
const options = {
|
|
8
|
-
path: path,
|
|
9
|
-
httpMethod: httpMethod,
|
|
10
|
-
handler: descriptor,
|
|
11
|
-
};
|
|
12
|
-
return apply(methodMetadata(Metadata.key(key, prop), options))(obj, prop, descriptor);
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
return Decoration.for(key)
|
|
16
|
-
.define({
|
|
17
|
-
decorator: route,
|
|
18
|
-
args: [],
|
|
19
|
-
})
|
|
20
|
-
.apply();
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=route.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../src/decaf-model/decorators/route.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,UAAU,EACV,QAAQ,EACR,cAAc,GACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,6BAAwB;AAI9C,MAAM,UAAU,KAAK,CAAC,UAAqB,EAAE,IAAY;IACvD,MAAM,GAAG,GAAG,WAAW,CAAC;IACxB,SAAS,KAAK;QACZ,OAAO,SAAS,KAAK,CAAC,GAAW,EAAE,IAAU,EAAE,UAAgB;YAC7D,MAAM,OAAO,GAAyB;gBACpC,IAAI,EAAE,IAAI;gBACV,UAAU,EAAE,UAAU;gBACtB,OAAO,EAAE,UAAU;aACpB,CAAC;YAEF,OAAO,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,CAC5D,GAAG,EACH,IAAI,EACJ,UAAU,CACX,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC;SACvB,MAAM,CAAC;QACN,SAAS,EAAE,KAAK;QAChB,IAAI,EAAE,EAAE;KACT,CAAC;SACD,KAAK,EAAE,CAAC;AACb,CAAC"}
|