@hed-hog/core 0.0.382 → 0.0.385
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/auth/auth.controller.d.ts +2 -2
- package/dist/auth/auth.service.d.ts +7 -7
- package/dist/auth/guards/auth.guard.d.ts.map +1 -1
- package/dist/auth/guards/auth.guard.js +14 -0
- package/dist/auth/guards/auth.guard.js.map +1 -1
- package/dist/mcp/decorators/allow-mcp-token.decorator.d.ts +3 -0
- package/dist/mcp/decorators/allow-mcp-token.decorator.d.ts.map +1 -0
- package/dist/mcp/decorators/allow-mcp-token.decorator.js +10 -0
- package/dist/mcp/decorators/allow-mcp-token.decorator.js.map +1 -0
- package/dist/mcp/mcp.controller.d.ts.map +1 -1
- package/dist/mcp/mcp.controller.js +2 -0
- package/dist/mcp/mcp.controller.js.map +1 -1
- package/dist/notification/notification.controller.d.ts +12 -12
- package/dist/notification/notification.service.d.ts +12 -12
- package/dist/session/session.controller.d.ts +1 -1
- package/dist/session/session.service.d.ts +3 -3
- package/dist/user/user.controller.d.ts +1 -1
- package/dist/user/user.service.d.ts +3 -3
- package/hedhog/frontend/app/roles/page.tsx.ejs +13 -12
- package/hedhog/frontend/messages/en.json +2 -1
- package/hedhog/frontend/messages/pt.json +2 -1
- package/package.json +5 -5
- package/src/auth/guards/auth.guard.spec.ts +49 -1
- package/src/auth/guards/auth.guard.ts +15 -0
- package/src/mcp/decorators/allow-mcp-token.decorator.ts +7 -0
- package/src/mcp/mcp.controller.ts +2 -0
|
@@ -81,10 +81,10 @@ export declare class AuthController {
|
|
|
81
81
|
created_at: Date;
|
|
82
82
|
updated_at: Date;
|
|
83
83
|
hash: string;
|
|
84
|
-
browser_id: string | null;
|
|
85
84
|
ip_address: string;
|
|
86
85
|
revoked_at: Date | null;
|
|
87
86
|
expires_at: Date;
|
|
87
|
+
browser_id: string | null;
|
|
88
88
|
}[];
|
|
89
89
|
id: number;
|
|
90
90
|
created_at: Date;
|
|
@@ -200,10 +200,10 @@ export declare class AuthController {
|
|
|
200
200
|
created_at: Date;
|
|
201
201
|
updated_at: Date;
|
|
202
202
|
hash: string;
|
|
203
|
-
browser_id: string | null;
|
|
204
203
|
ip_address: string;
|
|
205
204
|
revoked_at: Date | null;
|
|
206
205
|
expires_at: Date;
|
|
206
|
+
browser_id: string | null;
|
|
207
207
|
};
|
|
208
208
|
}>;
|
|
209
209
|
}
|
|
@@ -29,10 +29,10 @@ export declare class AuthService {
|
|
|
29
29
|
created_at: Date;
|
|
30
30
|
updated_at: Date;
|
|
31
31
|
hash: string;
|
|
32
|
-
browser_id: string | null;
|
|
33
32
|
ip_address: string;
|
|
34
33
|
revoked_at: Date | null;
|
|
35
34
|
expires_at: Date;
|
|
35
|
+
browser_id: string | null;
|
|
36
36
|
};
|
|
37
37
|
}>;
|
|
38
38
|
issueDesktopToken(locale: string, userId: number, ipAddress: string, userAgent: string): Promise<{
|
|
@@ -148,10 +148,10 @@ export declare class AuthService {
|
|
|
148
148
|
created_at: Date;
|
|
149
149
|
updated_at: Date;
|
|
150
150
|
hash: string;
|
|
151
|
-
browser_id: string | null;
|
|
152
151
|
ip_address: string;
|
|
153
152
|
revoked_at: Date | null;
|
|
154
153
|
expires_at: Date;
|
|
154
|
+
browser_id: string | null;
|
|
155
155
|
}[];
|
|
156
156
|
id: number;
|
|
157
157
|
created_at: Date;
|
|
@@ -173,10 +173,10 @@ export declare class AuthService {
|
|
|
173
173
|
created_at: Date;
|
|
174
174
|
updated_at: Date;
|
|
175
175
|
hash: string;
|
|
176
|
-
browser_id: string | null;
|
|
177
176
|
ip_address: string;
|
|
178
177
|
revoked_at: Date | null;
|
|
179
178
|
expires_at: Date;
|
|
179
|
+
browser_id: string | null;
|
|
180
180
|
};
|
|
181
181
|
}>;
|
|
182
182
|
forgotPassword(locale: string, { email, app }: ForgetDTO): Promise<{
|
|
@@ -195,10 +195,10 @@ export declare class AuthService {
|
|
|
195
195
|
created_at: Date;
|
|
196
196
|
updated_at: Date;
|
|
197
197
|
hash: string;
|
|
198
|
-
browser_id: string | null;
|
|
199
198
|
ip_address: string;
|
|
200
199
|
revoked_at: Date | null;
|
|
201
200
|
expires_at: Date;
|
|
201
|
+
browser_id: string | null;
|
|
202
202
|
};
|
|
203
203
|
}>;
|
|
204
204
|
verifyMfaCode(locale: string, mfaToken: string, code: string, ipAddress: string, userAgent: string, methodType?: 'totp' | 'email' | 'recovery', browserId?: string | null): Promise<{
|
|
@@ -211,10 +211,10 @@ export declare class AuthService {
|
|
|
211
211
|
created_at: Date;
|
|
212
212
|
updated_at: Date;
|
|
213
213
|
hash: string;
|
|
214
|
-
browser_id: string | null;
|
|
215
214
|
ip_address: string;
|
|
216
215
|
revoked_at: Date | null;
|
|
217
216
|
expires_at: Date;
|
|
217
|
+
browser_id: string | null;
|
|
218
218
|
};
|
|
219
219
|
requiresPasswordReset: boolean;
|
|
220
220
|
}>;
|
|
@@ -228,10 +228,10 @@ export declare class AuthService {
|
|
|
228
228
|
created_at: Date;
|
|
229
229
|
updated_at: Date;
|
|
230
230
|
hash: string;
|
|
231
|
-
browser_id: string | null;
|
|
232
231
|
ip_address: string;
|
|
233
232
|
revoked_at: Date | null;
|
|
234
233
|
expires_at: Date;
|
|
234
|
+
browser_id: string | null;
|
|
235
235
|
};
|
|
236
236
|
requiresPasswordReset: boolean;
|
|
237
237
|
}>;
|
|
@@ -250,10 +250,10 @@ export declare class AuthService {
|
|
|
250
250
|
created_at: Date;
|
|
251
251
|
updated_at: Date;
|
|
252
252
|
hash: string;
|
|
253
|
-
browser_id: string | null;
|
|
254
253
|
ip_address: string;
|
|
255
254
|
revoked_at: Date | null;
|
|
256
255
|
expires_at: Date;
|
|
256
|
+
browser_id: string | null;
|
|
257
257
|
};
|
|
258
258
|
requiresPasswordReset: boolean;
|
|
259
259
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.guard.d.ts","sourceRoot":"","sources":["../../../src/auth/guards/auth.guard.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACL,WAAW,EACX,gBAAgB,EAIjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.guard.d.ts","sourceRoot":"","sources":["../../../src/auth/guards/auth.guard.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACL,WAAW,EACX,gBAAgB,EAIjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,qBACa,SAAU,YAAW,WAAW;IAIzC,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,QAAQ;IANlB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8B;gBAG3C,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,eAAe;IAG7B,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;YAoFhD,YAAY;IAwB1B,OAAO,CAAC,sBAAsB;CAK/B"}
|
|
@@ -16,6 +16,7 @@ const api_locale_1 = require("@hed-hog/api-locale");
|
|
|
16
16
|
const api_prisma_1 = require("@hed-hog/api-prisma");
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
18
|
const core_1 = require("@nestjs/core");
|
|
19
|
+
const allow_mcp_token_decorator_1 = require("../../mcp/decorators/allow-mcp-token.decorator");
|
|
19
20
|
const security_service_1 = require("../../security/security.service");
|
|
20
21
|
const token_service_1 = require("../../token/token.service");
|
|
21
22
|
let AuthGuard = AuthGuard_1 = class AuthGuard {
|
|
@@ -40,12 +41,25 @@ let AuthGuard = AuthGuard_1 = class AuthGuard {
|
|
|
40
41
|
context.getHandler(),
|
|
41
42
|
context.getClass(),
|
|
42
43
|
]);
|
|
44
|
+
const allowMcpToken = this.reflector.getAllAndOverride(allow_mcp_token_decorator_1.ALLOW_MCP_TOKEN, [
|
|
45
|
+
context.getHandler(),
|
|
46
|
+
context.getClass(),
|
|
47
|
+
]);
|
|
43
48
|
const request = context.switchToHttp().getRequest();
|
|
44
49
|
const token = this.extractTokenFromHeader(request);
|
|
45
50
|
const locale = request.headers['locale'] || request.headers['accept-language'] || 'en';
|
|
46
51
|
if (token === null || token === void 0 ? void 0 : token.startsWith('hedhog_api_')) {
|
|
47
52
|
return this.verifyApiKey(request, token, isPublic);
|
|
48
53
|
}
|
|
54
|
+
if (token === null || token === void 0 ? void 0 : token.startsWith('hedhog_mcp_')) {
|
|
55
|
+
if (allowMcpToken) {
|
|
56
|
+
// Real validation (mcp_api_key lookup) happens in McpAuthGuard on /mcp.
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
if (isPublic)
|
|
60
|
+
return true;
|
|
61
|
+
throw new common_1.UnauthorizedException('Invalid API key');
|
|
62
|
+
}
|
|
49
63
|
// If endpoint requires role/authentication and no token provided
|
|
50
64
|
if (!token) {
|
|
51
65
|
if (isPublic) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.guard.js","sourceRoot":"","sources":["../../../src/auth/guards/auth.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,sCAAsE;AACtE,oDAAoD;AACpD,oDAAoD;AACpD,2CAMwB;AACxB,uCAAyC;AAEzC,sEAAkE;AAClE,6DAAyD;AAGlD,IAAM,SAAS,iBAAf,MAAM,SAAS;IAGpB,YACU,KAAmB,EACnB,SAAoB,EACpB,MAAqB,EACrB,QAAyB;QAHzB,UAAK,GAAL,KAAK,CAAc;QACnB,cAAS,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YAC7B,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE;YACxB,IAAI,EAAE,EAAE,YAAY,EAAE,IAAI,IAAI,EAAE,EAAE;SACnC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAEnB,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC3D,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,sBAAsB,CAAC,OAAgB;;QAC7C,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,MAAA,MAAA,OAAO,CAAC,OAAO,CAAC,aAAa,0CAAE,KAAK,CAAC,GAAG,CAAC,mCAAI,EAAE,CAAC;QAEtE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/C,CAAC;CACF,CAAA;AA3HY,8BAAS;oBAAT,SAAS;IADrB,IAAA,mBAAU,GAAE;qCAKM,4BAAY;QACR,gBAAS;QACZ,0BAAa;QACX,kCAAe;GAPxB,SAAS,CA2HrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allow-mcp-token.decorator.d.ts","sourceRoot":"","sources":["../../../src/mcp/decorators/allow-mcp-token.decorator.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,kBAAkB,CAAC;AAE/C,wBAAgB,aAAa,qDAE5B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ALLOW_MCP_TOKEN = void 0;
|
|
4
|
+
exports.AllowMcpToken = AllowMcpToken;
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
exports.ALLOW_MCP_TOKEN = 'allowMcpToken';
|
|
7
|
+
function AllowMcpToken() {
|
|
8
|
+
return (0, common_1.SetMetadata)(exports.ALLOW_MCP_TOKEN, true);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=allow-mcp-token.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allow-mcp-token.decorator.js","sourceRoot":"","sources":["../../../src/mcp/decorators/allow-mcp-token.decorator.ts"],"names":[],"mappings":";;;AAIA,sCAEC;AAND,2CAA6C;AAEhC,QAAA,eAAe,GAAG,eAAe,CAAC;AAE/C,SAAgB,aAAa;IAC3B,OAAO,IAAA,oBAAW,EAAC,uBAAe,EAAE,IAAI,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.controller.d.ts","sourceRoot":"","sources":["../../src/mcp/mcp.controller.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp.controller.d.ts","sourceRoot":"","sources":["../../src/mcp/mcp.controller.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAI5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,qBAIa,aAAa;IAEtB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO;gBADP,SAAS,EAAE,gBAAgB,EAC3B,OAAO,EAAE,cAAc;IAIpC,MAAM,CAAQ,GAAG,EAAE,OAAO,EAAS,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAqBvE"}
|
|
@@ -16,6 +16,7 @@ exports.McpController = void 0;
|
|
|
16
16
|
const api_1 = require("@hed-hog/api");
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
18
|
const setting_service_1 = require("../setting/setting.service");
|
|
19
|
+
const allow_mcp_token_decorator_1 = require("./decorators/allow-mcp-token.decorator");
|
|
19
20
|
const mcp_auth_guard_1 = require("./guards/mcp-auth.guard");
|
|
20
21
|
const mcp_permission_guard_1 = require("./guards/mcp-permission.guard");
|
|
21
22
|
const mcp_server_service_1 = require("./mcp-server.service");
|
|
@@ -54,6 +55,7 @@ __decorate([
|
|
|
54
55
|
], McpController.prototype, "handle", null);
|
|
55
56
|
exports.McpController = McpController = __decorate([
|
|
56
57
|
(0, api_1.NoRole)(),
|
|
58
|
+
(0, allow_mcp_token_decorator_1.AllowMcpToken)(),
|
|
57
59
|
(0, common_1.UseGuards)(mcp_auth_guard_1.McpAuthGuard, mcp_permission_guard_1.McpPermissionGuard),
|
|
58
60
|
(0, common_1.Controller)('mcp'),
|
|
59
61
|
__metadata("design:paramtypes", [mcp_server_service_1.McpServerService,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.controller.js","sourceRoot":"","sources":["../../src/mcp/mcp.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sCAAsC;AACtC,2CAAsE;AAEtE,gEAA4D;AAC5D,4DAAuD;AACvD,wEAAmE;AACnE,6DAAwD;
|
|
1
|
+
{"version":3,"file":"mcp.controller.js","sourceRoot":"","sources":["../../src/mcp/mcp.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sCAAsC;AACtC,2CAAsE;AAEtE,gEAA4D;AAC5D,sFAAuE;AACvE,4DAAuD;AACvD,wEAAmE;AACnE,6DAAwD;AAMjD,IAAM,aAAa,GAAnB,MAAM,aAAa;IACxB,YACmB,SAA2B,EAC3B,OAAuB;QADvB,cAAS,GAAT,SAAS,CAAkB;QAC3B,YAAO,GAAP,OAAO,CAAgB;IACvC,CAAC;IAGE,AAAN,KAAK,CAAC,MAAM,CAAQ,GAAY,EAAS,GAAa;;QACpD,MAAM,Q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EAAC,6BAAY,EAAE,yCAAkB,CAAC;IAC3C,IAAA,mBAAU,EAAC,KAAK,CAAC;qCAGc,qCAAgB;QAClB,gCAAc;GAH/B,aAAa,CA4BzB"}
|
|
@@ -34,13 +34,13 @@ export declare class NotificationController {
|
|
|
34
34
|
user_id: number;
|
|
35
35
|
created_at: Date;
|
|
36
36
|
updated_at: Date;
|
|
37
|
-
type: import("@prisma/client").$Enums.
|
|
37
|
+
type: import("@prisma/client").$Enums.notification_type_enum;
|
|
38
38
|
body: string | null;
|
|
39
|
-
status: import("@prisma/client").$Enums.
|
|
39
|
+
status: import("@prisma/client").$Enums.notification_status_enum;
|
|
40
40
|
icon: string | null;
|
|
41
41
|
title: string;
|
|
42
42
|
progress: number | null;
|
|
43
|
-
action_type: import("@prisma/client").$Enums.
|
|
43
|
+
action_type: import("@prisma/client").$Enums.notification_action_type_enum | null;
|
|
44
44
|
action_data: import("@prisma/client/runtime/library").JsonValue | null;
|
|
45
45
|
action_url: string | null;
|
|
46
46
|
auto_remove: boolean;
|
|
@@ -54,13 +54,13 @@ export declare class NotificationController {
|
|
|
54
54
|
user_id: number;
|
|
55
55
|
created_at: Date;
|
|
56
56
|
updated_at: Date;
|
|
57
|
-
type: import("@prisma/client").$Enums.
|
|
57
|
+
type: import("@prisma/client").$Enums.notification_type_enum;
|
|
58
58
|
body: string | null;
|
|
59
|
-
status: import("@prisma/client").$Enums.
|
|
59
|
+
status: import("@prisma/client").$Enums.notification_status_enum;
|
|
60
60
|
icon: string | null;
|
|
61
61
|
title: string;
|
|
62
62
|
progress: number | null;
|
|
63
|
-
action_type: import("@prisma/client").$Enums.
|
|
63
|
+
action_type: import("@prisma/client").$Enums.notification_action_type_enum | null;
|
|
64
64
|
action_data: import("@prisma/client/runtime/library").JsonValue | null;
|
|
65
65
|
action_url: string | null;
|
|
66
66
|
auto_remove: boolean;
|
|
@@ -77,13 +77,13 @@ export declare class NotificationController {
|
|
|
77
77
|
user_id: number;
|
|
78
78
|
created_at: Date;
|
|
79
79
|
updated_at: Date;
|
|
80
|
-
type: import("@prisma/client").$Enums.
|
|
80
|
+
type: import("@prisma/client").$Enums.notification_type_enum;
|
|
81
81
|
body: string | null;
|
|
82
|
-
status: import("@prisma/client").$Enums.
|
|
82
|
+
status: import("@prisma/client").$Enums.notification_status_enum;
|
|
83
83
|
icon: string | null;
|
|
84
84
|
title: string;
|
|
85
85
|
progress: number | null;
|
|
86
|
-
action_type: import("@prisma/client").$Enums.
|
|
86
|
+
action_type: import("@prisma/client").$Enums.notification_action_type_enum | null;
|
|
87
87
|
action_data: import("@prisma/client/runtime/library").JsonValue | null;
|
|
88
88
|
action_url: string | null;
|
|
89
89
|
auto_remove: boolean;
|
|
@@ -95,13 +95,13 @@ export declare class NotificationController {
|
|
|
95
95
|
user_id: number;
|
|
96
96
|
created_at: Date;
|
|
97
97
|
updated_at: Date;
|
|
98
|
-
type: import("@prisma/client").$Enums.
|
|
98
|
+
type: import("@prisma/client").$Enums.notification_type_enum;
|
|
99
99
|
body: string | null;
|
|
100
|
-
status: import("@prisma/client").$Enums.
|
|
100
|
+
status: import("@prisma/client").$Enums.notification_status_enum;
|
|
101
101
|
icon: string | null;
|
|
102
102
|
title: string;
|
|
103
103
|
progress: number | null;
|
|
104
|
-
action_type: import("@prisma/client").$Enums.
|
|
104
|
+
action_type: import("@prisma/client").$Enums.notification_action_type_enum | null;
|
|
105
105
|
action_data: import("@prisma/client/runtime/library").JsonValue | null;
|
|
106
106
|
action_url: string | null;
|
|
107
107
|
auto_remove: boolean;
|
|
@@ -36,13 +36,13 @@ export declare class NotificationService implements OnModuleInit, OnModuleDestro
|
|
|
36
36
|
user_id: number;
|
|
37
37
|
created_at: Date;
|
|
38
38
|
updated_at: Date;
|
|
39
|
-
type: import("@prisma/client").$Enums.
|
|
39
|
+
type: import("@prisma/client").$Enums.notification_type_enum;
|
|
40
40
|
body: string | null;
|
|
41
|
-
status: import("@prisma/client").$Enums.
|
|
41
|
+
status: import("@prisma/client").$Enums.notification_status_enum;
|
|
42
42
|
icon: string | null;
|
|
43
43
|
title: string;
|
|
44
44
|
progress: number | null;
|
|
45
|
-
action_type: import("@prisma/client").$Enums.
|
|
45
|
+
action_type: import("@prisma/client").$Enums.notification_action_type_enum | null;
|
|
46
46
|
action_data: import("@prisma/client/runtime/library").JsonValue | null;
|
|
47
47
|
action_url: string | null;
|
|
48
48
|
auto_remove: boolean;
|
|
@@ -55,13 +55,13 @@ export declare class NotificationService implements OnModuleInit, OnModuleDestro
|
|
|
55
55
|
user_id: number;
|
|
56
56
|
created_at: Date;
|
|
57
57
|
updated_at: Date;
|
|
58
|
-
type: import("@prisma/client").$Enums.
|
|
58
|
+
type: import("@prisma/client").$Enums.notification_type_enum;
|
|
59
59
|
body: string | null;
|
|
60
|
-
status: import("@prisma/client").$Enums.
|
|
60
|
+
status: import("@prisma/client").$Enums.notification_status_enum;
|
|
61
61
|
icon: string | null;
|
|
62
62
|
title: string;
|
|
63
63
|
progress: number | null;
|
|
64
|
-
action_type: import("@prisma/client").$Enums.
|
|
64
|
+
action_type: import("@prisma/client").$Enums.notification_action_type_enum | null;
|
|
65
65
|
action_data: import("@prisma/client/runtime/library").JsonValue | null;
|
|
66
66
|
action_url: string | null;
|
|
67
67
|
auto_remove: boolean;
|
|
@@ -74,13 +74,13 @@ export declare class NotificationService implements OnModuleInit, OnModuleDestro
|
|
|
74
74
|
user_id: number;
|
|
75
75
|
created_at: Date;
|
|
76
76
|
updated_at: Date;
|
|
77
|
-
type: import("@prisma/client").$Enums.
|
|
77
|
+
type: import("@prisma/client").$Enums.notification_type_enum;
|
|
78
78
|
body: string | null;
|
|
79
|
-
status: import("@prisma/client").$Enums.
|
|
79
|
+
status: import("@prisma/client").$Enums.notification_status_enum;
|
|
80
80
|
icon: string | null;
|
|
81
81
|
title: string;
|
|
82
82
|
progress: number | null;
|
|
83
|
-
action_type: import("@prisma/client").$Enums.
|
|
83
|
+
action_type: import("@prisma/client").$Enums.notification_action_type_enum | null;
|
|
84
84
|
action_data: import("@prisma/client/runtime/library").JsonValue | null;
|
|
85
85
|
action_url: string | null;
|
|
86
86
|
auto_remove: boolean;
|
|
@@ -92,13 +92,13 @@ export declare class NotificationService implements OnModuleInit, OnModuleDestro
|
|
|
92
92
|
user_id: number;
|
|
93
93
|
created_at: Date;
|
|
94
94
|
updated_at: Date;
|
|
95
|
-
type: import("@prisma/client").$Enums.
|
|
95
|
+
type: import("@prisma/client").$Enums.notification_type_enum;
|
|
96
96
|
body: string | null;
|
|
97
|
-
status: import("@prisma/client").$Enums.
|
|
97
|
+
status: import("@prisma/client").$Enums.notification_status_enum;
|
|
98
98
|
icon: string | null;
|
|
99
99
|
title: string;
|
|
100
100
|
progress: number | null;
|
|
101
|
-
action_type: import("@prisma/client").$Enums.
|
|
101
|
+
action_type: import("@prisma/client").$Enums.notification_action_type_enum | null;
|
|
102
102
|
action_data: import("@prisma/client/runtime/library").JsonValue | null;
|
|
103
103
|
action_url: string | null;
|
|
104
104
|
auto_remove: boolean;
|
|
@@ -36,10 +36,10 @@ export declare class SessionController {
|
|
|
36
36
|
created_at: Date;
|
|
37
37
|
updated_at: Date;
|
|
38
38
|
hash: string;
|
|
39
|
-
browser_id: string | null;
|
|
40
39
|
ip_address: string;
|
|
41
40
|
revoked_at: Date | null;
|
|
42
41
|
expires_at: Date;
|
|
42
|
+
browser_id: string | null;
|
|
43
43
|
}>;
|
|
44
44
|
}
|
|
45
45
|
//# sourceMappingURL=session.controller.d.ts.map
|
|
@@ -24,10 +24,10 @@ export declare class SessionService {
|
|
|
24
24
|
created_at: Date;
|
|
25
25
|
updated_at: Date;
|
|
26
26
|
hash: string;
|
|
27
|
-
browser_id: string | null;
|
|
28
27
|
ip_address: string;
|
|
29
28
|
revoked_at: Date | null;
|
|
30
29
|
expires_at: Date;
|
|
30
|
+
browser_id: string | null;
|
|
31
31
|
};
|
|
32
32
|
}>;
|
|
33
33
|
refresh(locale: string, refreshToken: string, ipAddress: string, userAgent: string, browserId?: string | null): Promise<{
|
|
@@ -39,10 +39,10 @@ export declare class SessionService {
|
|
|
39
39
|
created_at: Date;
|
|
40
40
|
updated_at: Date;
|
|
41
41
|
hash: string;
|
|
42
|
-
browser_id: string | null;
|
|
43
42
|
ip_address: string;
|
|
44
43
|
revoked_at: Date | null;
|
|
45
44
|
expires_at: Date;
|
|
45
|
+
browser_id: string | null;
|
|
46
46
|
};
|
|
47
47
|
}>;
|
|
48
48
|
deleteRefreshTokenCookie(res: any, refreshToken: string): Promise<{
|
|
@@ -74,10 +74,10 @@ export declare class SessionService {
|
|
|
74
74
|
created_at: Date;
|
|
75
75
|
updated_at: Date;
|
|
76
76
|
hash: string;
|
|
77
|
-
browser_id: string | null;
|
|
78
77
|
ip_address: string;
|
|
79
78
|
revoked_at: Date | null;
|
|
80
79
|
expires_at: Date;
|
|
80
|
+
browser_id: string | null;
|
|
81
81
|
}>;
|
|
82
82
|
/**
|
|
83
83
|
* Enforce maximum concurrent sessions limit for a user.
|
|
@@ -83,10 +83,10 @@ export declare class UserController {
|
|
|
83
83
|
created_at: Date;
|
|
84
84
|
updated_at: Date;
|
|
85
85
|
hash: string;
|
|
86
|
-
browser_id: string | null;
|
|
87
86
|
ip_address: string;
|
|
88
87
|
revoked_at: Date | null;
|
|
89
88
|
expires_at: Date;
|
|
89
|
+
browser_id: string | null;
|
|
90
90
|
}[];
|
|
91
91
|
} & {
|
|
92
92
|
id: number;
|
|
@@ -108,10 +108,10 @@ export declare class UserService {
|
|
|
108
108
|
created_at: Date;
|
|
109
109
|
updated_at: Date;
|
|
110
110
|
hash: string;
|
|
111
|
-
browser_id: string | null;
|
|
112
111
|
ip_address: string;
|
|
113
112
|
revoked_at: Date | null;
|
|
114
113
|
expires_at: Date;
|
|
114
|
+
browser_id: string | null;
|
|
115
115
|
}[];
|
|
116
116
|
} & {
|
|
117
117
|
id: number;
|
|
@@ -223,10 +223,10 @@ export declare class UserService {
|
|
|
223
223
|
created_at: Date;
|
|
224
224
|
updated_at: Date;
|
|
225
225
|
hash: string;
|
|
226
|
-
browser_id: string | null;
|
|
227
226
|
ip_address: string;
|
|
228
227
|
revoked_at: Date | null;
|
|
229
228
|
expires_at: Date;
|
|
229
|
+
browser_id: string | null;
|
|
230
230
|
}[];
|
|
231
231
|
} & {
|
|
232
232
|
id: number;
|
|
@@ -268,10 +268,10 @@ export declare class UserService {
|
|
|
268
268
|
created_at: Date;
|
|
269
269
|
updated_at: Date;
|
|
270
270
|
hash: string;
|
|
271
|
-
browser_id: string | null;
|
|
272
271
|
ip_address: string;
|
|
273
272
|
revoked_at: Date | null;
|
|
274
273
|
expires_at: Date;
|
|
274
|
+
browser_id: string | null;
|
|
275
275
|
}[];
|
|
276
276
|
} & {
|
|
277
277
|
id: number;
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
PageHeader,
|
|
7
7
|
PaginationFooter,
|
|
8
8
|
SearchBar,
|
|
9
|
-
StatsCards,
|
|
10
9
|
} from '@/components/entity-list';
|
|
11
10
|
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
|
|
12
11
|
import {
|
|
@@ -36,6 +35,7 @@ import {
|
|
|
36
35
|
FormMessage,
|
|
37
36
|
} from '@/components/ui/form';
|
|
38
37
|
import { Input } from '@/components/ui/input';
|
|
38
|
+
import { KpiCardsGrid, type KpiCardItem } from '@/components/ui/kpi-cards-grid';
|
|
39
39
|
import {
|
|
40
40
|
Select,
|
|
41
41
|
SelectContent,
|
|
@@ -594,17 +594,18 @@ export default function RolePage() {
|
|
|
594
594
|
description={t('description')}
|
|
595
595
|
/>
|
|
596
596
|
|
|
597
|
-
<
|
|
598
|
-
className="
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
597
|
+
<KpiCardsGrid
|
|
598
|
+
className="grid-cols-1 md:grid-cols-1 xl:grid-cols-1"
|
|
599
|
+
items={
|
|
600
|
+
[
|
|
601
|
+
{
|
|
602
|
+
key: 'totalRoles',
|
|
603
|
+
title: t('totalRoles'),
|
|
604
|
+
value: stats.totalRoles,
|
|
605
|
+
icon: ShieldCheck,
|
|
606
|
+
},
|
|
607
|
+
] satisfies KpiCardItem[]
|
|
608
|
+
}
|
|
608
609
|
/>
|
|
609
610
|
|
|
610
611
|
<SearchBar
|
|
@@ -2138,7 +2138,8 @@
|
|
|
2138
2138
|
"breadcrumbDashboard": "Dashboard",
|
|
2139
2139
|
"breadcrumbManagement": "Management",
|
|
2140
2140
|
"breadcrumbCurrent": "MCP Chat",
|
|
2141
|
-
"mcpDisabled": "MCP Server is disabled. Enable it in Settings → MCP."
|
|
2141
|
+
"mcpDisabled": "MCP Server is disabled. Enable it in Settings → MCP.",
|
|
2142
|
+
"resizePanel": "Resize panel"
|
|
2142
2143
|
},
|
|
2143
2144
|
"McpTokens": {
|
|
2144
2145
|
"title": "MCP API Keys",
|
|
@@ -2193,7 +2193,8 @@
|
|
|
2193
2193
|
"breadcrumbDashboard": "Painel",
|
|
2194
2194
|
"breadcrumbManagement": "Gerenciamento",
|
|
2195
2195
|
"breadcrumbCurrent": "Chat MCP",
|
|
2196
|
-
"mcpDisabled": "O Servidor MCP está desabilitado. Habilite-o em Configurações → MCP."
|
|
2196
|
+
"mcpDisabled": "O Servidor MCP está desabilitado. Habilite-o em Configurações → MCP.",
|
|
2197
|
+
"resizePanel": "Redimensionar painel"
|
|
2197
2198
|
},
|
|
2198
2199
|
"McpTokens": {
|
|
2199
2200
|
"title": "Chaves de API MCP",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hed-hog/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.385",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"ua-parser-js": "^2.0.10",
|
|
43
43
|
"uuid": "^11.1.0",
|
|
44
44
|
"@hed-hog/api-prisma": "0.0.6",
|
|
45
|
-
"@hed-hog/api-
|
|
46
|
-
"@hed-hog/api": "0.0.8",
|
|
45
|
+
"@hed-hog/api-locale": "0.0.14",
|
|
47
46
|
"@hed-hog/api-types": "0.0.1",
|
|
48
|
-
"@hed-hog/api
|
|
49
|
-
"@hed-hog/api-
|
|
47
|
+
"@hed-hog/api": "0.0.8",
|
|
48
|
+
"@hed-hog/api-mail": "0.0.9",
|
|
49
|
+
"@hed-hog/api-pagination": "0.0.7"
|
|
50
50
|
},
|
|
51
51
|
"exports": {
|
|
52
52
|
".": {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect, beforeEach, afterEach, jest } from '@jest/globals';
|
|
2
2
|
import { UnauthorizedException } from '@nestjs/common';
|
|
3
3
|
import { IS_PUBLIC_KEY, WITH_NO_ROLE, WITH_ROLE } from '@hed-hog/api';
|
|
4
|
+
import { ALLOW_MCP_TOKEN } from '../../mcp/decorators/allow-mcp-token.decorator';
|
|
4
5
|
import { AuthGuard } from './auth.guard';
|
|
5
6
|
|
|
6
7
|
const makeContext = (request: any) => ({
|
|
@@ -29,12 +30,18 @@ const makeService = (deps = makeDeps()) => ({
|
|
|
29
30
|
|
|
30
31
|
const setMeta = (
|
|
31
32
|
reflector: any,
|
|
32
|
-
meta: {
|
|
33
|
+
meta: {
|
|
34
|
+
public?: boolean;
|
|
35
|
+
withRole?: boolean;
|
|
36
|
+
withNoRole?: boolean;
|
|
37
|
+
allowMcpToken?: boolean;
|
|
38
|
+
},
|
|
33
39
|
) => {
|
|
34
40
|
reflector.getAllAndOverride.mockImplementation((key: any) => {
|
|
35
41
|
if (key === IS_PUBLIC_KEY) return meta.public;
|
|
36
42
|
if (key === WITH_ROLE) return meta.withRole;
|
|
37
43
|
if (key === WITH_NO_ROLE) return meta.withNoRole;
|
|
44
|
+
if (key === ALLOW_MCP_TOKEN) return meta.allowMcpToken;
|
|
38
45
|
return undefined;
|
|
39
46
|
});
|
|
40
47
|
};
|
|
@@ -174,4 +181,45 @@ describe('AuthGuard', () => {
|
|
|
174
181
|
);
|
|
175
182
|
});
|
|
176
183
|
});
|
|
184
|
+
|
|
185
|
+
describe('mcp token (hedhog_mcp_)', () => {
|
|
186
|
+
it('defere para o McpAuthGuard quando a rota permite (allowMcpToken)', async () => {
|
|
187
|
+
const { guard, deps } = makeService();
|
|
188
|
+
setMeta(deps.reflector, { allowMcpToken: true });
|
|
189
|
+
const request: any = {
|
|
190
|
+
headers: { authorization: 'Bearer hedhog_mcp_x' },
|
|
191
|
+
};
|
|
192
|
+
await expect(guard.canActivate(makeContext(request) as any)).resolves.toBe(
|
|
193
|
+
true,
|
|
194
|
+
);
|
|
195
|
+
expect(deps.token.verify).not.toHaveBeenCalled();
|
|
196
|
+
expect(deps.prisma.mcp_api_key.findFirst).not.toHaveBeenCalled();
|
|
197
|
+
expect(request.auth).toBeUndefined();
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it('nega em rota sem allowMcpToken, sem tentar validar como JWT', async () => {
|
|
201
|
+
const { guard, deps } = makeService();
|
|
202
|
+
setMeta(deps.reflector, {});
|
|
203
|
+
const request: any = {
|
|
204
|
+
headers: { authorization: 'Bearer hedhog_mcp_x' },
|
|
205
|
+
method: 'GET',
|
|
206
|
+
url: '/profile',
|
|
207
|
+
};
|
|
208
|
+
await expect(guard.canActivate(makeContext(request) as any)).rejects.toThrow(
|
|
209
|
+
UnauthorizedException,
|
|
210
|
+
);
|
|
211
|
+
expect(deps.token.verify).not.toHaveBeenCalled();
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it('permite em rota pública sem allowMcpToken', async () => {
|
|
215
|
+
const { guard, deps } = makeService();
|
|
216
|
+
setMeta(deps.reflector, { public: true });
|
|
217
|
+
const request: any = {
|
|
218
|
+
headers: { authorization: 'Bearer hedhog_mcp_x' },
|
|
219
|
+
};
|
|
220
|
+
await expect(guard.canActivate(makeContext(request) as any)).resolves.toBe(
|
|
221
|
+
true,
|
|
222
|
+
);
|
|
223
|
+
});
|
|
224
|
+
});
|
|
177
225
|
});
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from '@nestjs/common';
|
|
11
11
|
import { Reflector } from '@nestjs/core';
|
|
12
12
|
import { Request } from 'express';
|
|
13
|
+
import { ALLOW_MCP_TOKEN } from '../../mcp/decorators/allow-mcp-token.decorator';
|
|
13
14
|
import { SecurityService } from '../../security/security.service';
|
|
14
15
|
import { TokenService } from '../../token/token.service';
|
|
15
16
|
|
|
@@ -40,6 +41,11 @@ export class AuthGuard implements CanActivate {
|
|
|
40
41
|
context.getClass(),
|
|
41
42
|
]);
|
|
42
43
|
|
|
44
|
+
const allowMcpToken = this.reflector.getAllAndOverride<boolean>(ALLOW_MCP_TOKEN, [
|
|
45
|
+
context.getHandler(),
|
|
46
|
+
context.getClass(),
|
|
47
|
+
]);
|
|
48
|
+
|
|
43
49
|
const request = context.switchToHttp().getRequest();
|
|
44
50
|
const token = this.extractTokenFromHeader(request);
|
|
45
51
|
const locale = request.headers['locale'] || request.headers['accept-language'] || 'en';
|
|
@@ -48,6 +54,15 @@ export class AuthGuard implements CanActivate {
|
|
|
48
54
|
return this.verifyApiKey(request, token, isPublic);
|
|
49
55
|
}
|
|
50
56
|
|
|
57
|
+
if (token?.startsWith('hedhog_mcp_')) {
|
|
58
|
+
if (allowMcpToken) {
|
|
59
|
+
// Real validation (mcp_api_key lookup) happens in McpAuthGuard on /mcp.
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
if (isPublic) return true;
|
|
63
|
+
throw new UnauthorizedException('Invalid API key');
|
|
64
|
+
}
|
|
65
|
+
|
|
51
66
|
// If endpoint requires role/authentication and no token provided
|
|
52
67
|
if (!token) {
|
|
53
68
|
if (isPublic) {
|
|
@@ -2,11 +2,13 @@ import { NoRole } from '@hed-hog/api';
|
|
|
2
2
|
import { All, Controller, Req, Res, UseGuards } from '@nestjs/common';
|
|
3
3
|
import { Request, Response } from 'express';
|
|
4
4
|
import { SettingService } from '../setting/setting.service';
|
|
5
|
+
import { AllowMcpToken } from './decorators/allow-mcp-token.decorator';
|
|
5
6
|
import { McpAuthGuard } from './guards/mcp-auth.guard';
|
|
6
7
|
import { McpPermissionGuard } from './guards/mcp-permission.guard';
|
|
7
8
|
import { McpServerService } from './mcp-server.service';
|
|
8
9
|
|
|
9
10
|
@NoRole()
|
|
11
|
+
@AllowMcpToken()
|
|
10
12
|
@UseGuards(McpAuthGuard, McpPermissionGuard)
|
|
11
13
|
@Controller('mcp')
|
|
12
14
|
export class McpController {
|