itlab-internal-services 0.0.2 → 0.0.4
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/guards/internal.guard.js +7 -2
- package/dist/guards/jwt.guard.js +6 -2
- package/dist/guards/perms.guard.js +22 -4
- package/dist/services/comment.service.d.ts +2 -2
- package/dist/services/comment.service.js +3 -3
- package/dist/services/content.service.d.ts +2 -2
- package/dist/services/content.service.js +3 -3
- package/dist/services/search.service.d.ts +2 -2
- package/dist/services/search.service.js +3 -3
- package/package.json +1 -1
|
@@ -31,15 +31,20 @@ let InternalGuard = class InternalGuard {
|
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
InternalGuard = __decorate([
|
|
34
|
+
(0, common_1.Injectable)(),
|
|
34
35
|
__param(0, (0, common_1.Inject)(internal_constants_1.INTERNAL_MODULE_HEADER_TOKEN)),
|
|
35
36
|
__metadata("design:paramtypes", [String])
|
|
36
37
|
], InternalGuard);
|
|
37
38
|
exports.InternalGuard = InternalGuard;
|
|
38
|
-
class UnauthorizedApplicationException extends common_1.HttpException {
|
|
39
|
+
let UnauthorizedApplicationException = class UnauthorizedApplicationException extends common_1.HttpException {
|
|
39
40
|
constructor() {
|
|
40
41
|
super('Application unauthorized', common_1.HttpStatus.UNAUTHORIZED);
|
|
41
42
|
}
|
|
42
|
-
}
|
|
43
|
+
};
|
|
44
|
+
UnauthorizedApplicationException = __decorate([
|
|
45
|
+
(0, common_1.Injectable)(),
|
|
46
|
+
__metadata("design:paramtypes", [])
|
|
47
|
+
], UnauthorizedApplicationException);
|
|
43
48
|
exports.UnauthorizedApplicationException = UnauthorizedApplicationException;
|
|
44
49
|
const Internal = () => (0, common_1.applyDecorators)((0, swagger_1.ApiBasicAuth)(exports.INTERNAL_HEADER_KEY), (0, common_1.UseGuards)(InternalGuard), (0, swagger_1.ApiUnauthorizedResponse)({ description: 'Application unauthorized' }));
|
|
45
50
|
exports.Internal = Internal;
|
package/dist/guards/jwt.guard.js
CHANGED
|
@@ -31,6 +31,7 @@ let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(pas
|
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
JwtStrategy = __decorate([
|
|
34
|
+
(0, common_1.Injectable)(),
|
|
34
35
|
__param(0, (0, common_1.Inject)(internal_constants_1.INTERNAL_MODULE_JWT_SECRET)),
|
|
35
36
|
__metadata("design:paramtypes", [String])
|
|
36
37
|
], JwtStrategy);
|
|
@@ -47,8 +48,11 @@ exports.JwtToken = (0, common_1.createParamDecorator)((_, ctx) => {
|
|
|
47
48
|
const h = ctx.switchToHttp().getRequest().header('Authorization');
|
|
48
49
|
return h.replace('Bearer ', '');
|
|
49
50
|
});
|
|
50
|
-
class JwtGuard extends (0, passport_1.AuthGuard)('jwt') {
|
|
51
|
-
}
|
|
51
|
+
let JwtGuard = class JwtGuard extends (0, passport_1.AuthGuard)('jwt') {
|
|
52
|
+
};
|
|
53
|
+
JwtGuard = __decorate([
|
|
54
|
+
(0, common_1.Injectable)()
|
|
55
|
+
], JwtGuard);
|
|
52
56
|
exports.JwtGuard = JwtGuard;
|
|
53
57
|
const Jwt = () => (0, common_1.applyDecorators)((0, common_1.UseGuards)(JwtGuard), (0, swagger_1.ApiBearerAuth)(), (0, swagger_1.ApiUnauthorizedResponse)({ description: 'Unauthorized' }));
|
|
54
58
|
exports.Jwt = Jwt;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.Perms = exports.InsufficientPermissionsException = exports.PermsGuard = void 0;
|
|
4
13
|
const common_1 = require("@nestjs/common");
|
|
14
|
+
const core_1 = require("@nestjs/core");
|
|
5
15
|
const swagger_1 = require("@nestjs/swagger");
|
|
6
16
|
const jwt_guard_1 = require("./jwt.guard");
|
|
7
17
|
const meta = 'permsguard';
|
|
@@ -11,7 +21,7 @@ function transformPermissions(permissions) {
|
|
|
11
21
|
});
|
|
12
22
|
return [...new Set(mapped.flat())];
|
|
13
23
|
}
|
|
14
|
-
class PermsGuard {
|
|
24
|
+
let PermsGuard = class PermsGuard {
|
|
15
25
|
constructor(reflector) {
|
|
16
26
|
this.reflector = reflector;
|
|
17
27
|
}
|
|
@@ -30,13 +40,21 @@ class PermsGuard {
|
|
|
30
40
|
return true;
|
|
31
41
|
throw new InsufficientPermissionsException();
|
|
32
42
|
}
|
|
33
|
-
}
|
|
43
|
+
};
|
|
44
|
+
PermsGuard = __decorate([
|
|
45
|
+
(0, common_1.Injectable)(),
|
|
46
|
+
__metadata("design:paramtypes", [core_1.Reflector])
|
|
47
|
+
], PermsGuard);
|
|
34
48
|
exports.PermsGuard = PermsGuard;
|
|
35
|
-
class InsufficientPermissionsException extends common_1.HttpException {
|
|
49
|
+
let InsufficientPermissionsException = class InsufficientPermissionsException extends common_1.HttpException {
|
|
36
50
|
constructor() {
|
|
37
51
|
super('Insufficient permissions', common_1.HttpStatus.UNAUTHORIZED);
|
|
38
52
|
}
|
|
39
|
-
}
|
|
53
|
+
};
|
|
54
|
+
InsufficientPermissionsException = __decorate([
|
|
55
|
+
(0, common_1.Injectable)(),
|
|
56
|
+
__metadata("design:paramtypes", [])
|
|
57
|
+
], InsufficientPermissionsException);
|
|
40
58
|
exports.InsufficientPermissionsException = InsufficientPermissionsException;
|
|
41
59
|
const Perms = (...perms) => (0, common_1.applyDecorators)((0, common_1.SetMetadata)(meta, perms), (0, common_1.UseGuards)(jwt_guard_1.JwtGuard, PermsGuard), (0, swagger_1.ApiBearerAuth)(), (0, swagger_1.ApiOperation)({ summary: 'Perms: ' + perms.join(', ') }), (0, swagger_1.ApiUnauthorizedResponse)({
|
|
42
60
|
description: 'Unauthorized or insufficient permissions',
|
|
@@ -4,8 +4,8 @@ export declare type Comment = unknown;
|
|
|
4
4
|
export declare class CommentService {
|
|
5
5
|
protected readonly instance: AxiosInstance;
|
|
6
6
|
protected readonly target: Targets;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
constructor(instance?: AxiosInstance, target?: Targets);
|
|
8
|
+
protected prefix: string;
|
|
9
9
|
post(targetId: string, authorId: string, comment: Comment): Promise<Comment>;
|
|
10
10
|
delete(targetId: string): Promise<void>;
|
|
11
11
|
}
|
|
@@ -30,10 +30,10 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
30
30
|
const internal_constants_1 = require("../internal.constants");
|
|
31
31
|
const target_pipe_1 = require("../pipes/target.pipe");
|
|
32
32
|
let CommentService = class CommentService {
|
|
33
|
-
constructor(instance = axios_1.default, target = target_pipe_1.Targets.UNKNOWN
|
|
33
|
+
constructor(instance = axios_1.default, target = target_pipe_1.Targets.UNKNOWN) {
|
|
34
34
|
this.instance = instance;
|
|
35
35
|
this.target = target;
|
|
36
|
-
this.prefix =
|
|
36
|
+
this.prefix = 'comment/internal';
|
|
37
37
|
}
|
|
38
38
|
post(targetId, authorId, comment) {
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -59,6 +59,6 @@ let CommentService = class CommentService {
|
|
|
59
59
|
CommentService = __decorate([
|
|
60
60
|
__param(0, (0, common_1.Inject)(internal_constants_1.AXIOS_INSTANCE_TOKEN)),
|
|
61
61
|
__param(1, (0, common_1.Inject)(internal_constants_1.INTERNAL_MODULE_TARGET)),
|
|
62
|
-
__metadata("design:paramtypes", [Function, String
|
|
62
|
+
__metadata("design:paramtypes", [Function, String])
|
|
63
63
|
], CommentService);
|
|
64
64
|
exports.CommentService = CommentService;
|
|
@@ -4,8 +4,8 @@ export declare type Content = unknown[];
|
|
|
4
4
|
export declare class ContentService {
|
|
5
5
|
protected readonly instance: AxiosInstance;
|
|
6
6
|
protected readonly target: Targets;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
constructor(instance?: AxiosInstance, target?: Targets);
|
|
8
|
+
protected prefix: string;
|
|
9
9
|
verify(contents: Content): Promise<void>;
|
|
10
10
|
post(targetId: string, contents: Content): Promise<void>;
|
|
11
11
|
delete(targetId: string): Promise<void>;
|
|
@@ -30,10 +30,10 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
30
30
|
const internal_constants_1 = require("../internal.constants");
|
|
31
31
|
const target_pipe_1 = require("../pipes/target.pipe");
|
|
32
32
|
let ContentService = class ContentService {
|
|
33
|
-
constructor(instance = axios_1.default, target = target_pipe_1.Targets.UNKNOWN
|
|
33
|
+
constructor(instance = axios_1.default, target = target_pipe_1.Targets.UNKNOWN) {
|
|
34
34
|
this.instance = instance;
|
|
35
35
|
this.target = target;
|
|
36
|
-
this.prefix =
|
|
36
|
+
this.prefix = 'content/internal';
|
|
37
37
|
}
|
|
38
38
|
verify(contents) {
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -69,6 +69,6 @@ let ContentService = class ContentService {
|
|
|
69
69
|
ContentService = __decorate([
|
|
70
70
|
__param(0, (0, common_1.Inject)(internal_constants_1.AXIOS_INSTANCE_TOKEN)),
|
|
71
71
|
__param(1, (0, common_1.Inject)(internal_constants_1.INTERNAL_MODULE_TARGET)),
|
|
72
|
-
__metadata("design:paramtypes", [Function, String
|
|
72
|
+
__metadata("design:paramtypes", [Function, String])
|
|
73
73
|
], ContentService);
|
|
74
74
|
exports.ContentService = ContentService;
|
|
@@ -3,6 +3,6 @@ import { Targets } from '../pipes/target.pipe';
|
|
|
3
3
|
export declare class SearchService {
|
|
4
4
|
protected readonly instance: AxiosInstance;
|
|
5
5
|
protected readonly target: Targets;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
constructor(instance?: AxiosInstance, target?: Targets);
|
|
7
|
+
protected prefix: string;
|
|
8
8
|
}
|
|
@@ -21,15 +21,15 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
21
21
|
const internal_constants_1 = require("../internal.constants");
|
|
22
22
|
const target_pipe_1 = require("../pipes/target.pipe");
|
|
23
23
|
let SearchService = class SearchService {
|
|
24
|
-
constructor(instance = axios_1.default, target = target_pipe_1.Targets.UNKNOWN
|
|
24
|
+
constructor(instance = axios_1.default, target = target_pipe_1.Targets.UNKNOWN) {
|
|
25
25
|
this.instance = instance;
|
|
26
26
|
this.target = target;
|
|
27
|
-
this.prefix =
|
|
27
|
+
this.prefix = 'search/internal';
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
SearchService = __decorate([
|
|
31
31
|
__param(0, (0, common_1.Inject)(internal_constants_1.AXIOS_INSTANCE_TOKEN)),
|
|
32
32
|
__param(1, (0, common_1.Inject)(internal_constants_1.INTERNAL_MODULE_TARGET)),
|
|
33
|
-
__metadata("design:paramtypes", [Function, String
|
|
33
|
+
__metadata("design:paramtypes", [Function, String])
|
|
34
34
|
], SearchService);
|
|
35
35
|
exports.SearchService = SearchService;
|