@hed-hog/core 0.0.349 → 0.0.350
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 +3 -3
- package/dist/auth/auth.service.d.ts +8 -8
- package/dist/core.module.d.ts.map +1 -1
- package/dist/core.module.js +3 -0
- package/dist/core.module.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/guards/mcp-auth.guard.d.ts +6 -1
- package/dist/mcp/guards/mcp-auth.guard.d.ts.map +1 -1
- package/dist/mcp/guards/mcp-auth.guard.js +29 -2
- package/dist/mcp/guards/mcp-auth.guard.js.map +1 -1
- package/dist/mcp/mcp-api-key.controller.d.ts +32 -0
- package/dist/mcp/mcp-api-key.controller.d.ts.map +1 -0
- package/dist/mcp/mcp-api-key.controller.js +64 -0
- package/dist/mcp/mcp-api-key.controller.js.map +1 -0
- package/dist/mcp/mcp-api-key.service.d.ts +27 -0
- package/dist/mcp/mcp-api-key.service.d.ts.map +1 -0
- package/dist/mcp/mcp-api-key.service.js +74 -0
- package/dist/mcp/mcp-api-key.service.js.map +1 -0
- package/dist/mcp/mcp-registry.service.d.ts +1 -2
- package/dist/mcp/mcp-registry.service.d.ts.map +1 -1
- package/dist/mcp/mcp-registry.service.js +6 -2
- package/dist/mcp/mcp-registry.service.js.map +1 -1
- package/dist/mcp/mcp.module.d.ts.map +1 -1
- package/dist/mcp/mcp.module.js +8 -1
- package/dist/mcp/mcp.module.js.map +1 -1
- package/dist/mcp-chat/mcp-chat.controller.d.ts +4 -0
- package/dist/mcp-chat/mcp-chat.controller.d.ts.map +1 -1
- package/dist/mcp-chat/mcp-chat.controller.js +46 -0
- package/dist/mcp-chat/mcp-chat.controller.js.map +1 -1
- package/dist/mcp-chat/mcp-chat.service.d.ts +6 -1
- package/dist/mcp-chat/mcp-chat.service.d.ts.map +1 -1
- package/dist/mcp-chat/mcp-chat.service.js +125 -17
- package/dist/mcp-chat/mcp-chat.service.js.map +1 -1
- package/dist/notification/dto/create-notification.dto.d.ts +26 -0
- package/dist/notification/dto/create-notification.dto.d.ts.map +1 -0
- package/dist/notification/dto/create-notification.dto.js +86 -0
- package/dist/notification/dto/create-notification.dto.js.map +1 -0
- package/dist/notification/dto/update-progress.dto.d.ts +6 -0
- package/dist/notification/dto/update-progress.dto.d.ts.map +1 -0
- package/dist/notification/dto/update-progress.dto.js +33 -0
- package/dist/notification/dto/update-progress.dto.js.map +1 -0
- package/dist/notification/notification.controller.d.ts +108 -0
- package/dist/notification/notification.controller.d.ts.map +1 -0
- package/dist/notification/notification.controller.js +118 -0
- package/dist/notification/notification.controller.js.map +1 -0
- package/dist/notification/notification.module.d.ts +3 -0
- package/dist/notification/notification.module.d.ts.map +1 -0
- package/dist/notification/notification.module.js +29 -0
- package/dist/notification/notification.module.js.map +1 -0
- package/dist/notification/notification.service.d.ts +98 -0
- package/dist/notification/notification.service.d.ts.map +1 -0
- package/dist/notification/notification.service.js +123 -0
- package/dist/notification/notification.service.js.map +1 -0
- package/dist/profile/profile.controller.d.ts +1 -1
- package/dist/profile/profile.service.d.ts +1 -1
- package/dist/session/session.controller.d.ts +1 -1
- package/dist/session/session.service.d.ts +3 -3
- package/dist/setting/dto/update-setting-list.dto.d.ts +9 -0
- package/dist/setting/dto/update-setting-list.dto.d.ts.map +1 -0
- package/dist/setting/dto/update-setting-list.dto.js +44 -0
- package/dist/setting/dto/update-setting-list.dto.js.map +1 -0
- package/dist/setting/setting.controller.d.ts +19 -0
- package/dist/setting/setting.controller.d.ts.map +1 -1
- package/dist/setting/setting.controller.js +12 -0
- package/dist/setting/setting.controller.js.map +1 -1
- package/dist/setting/setting.service.d.ts +19 -0
- package/dist/setting/setting.service.d.ts.map +1 -1
- package/dist/setting/setting.service.js +79 -0
- package/dist/setting/setting.service.js.map +1 -1
- package/dist/task/task.service.d.ts +12 -0
- package/dist/task/task.service.d.ts.map +1 -1
- package/dist/task/task.service.js +60 -0
- package/dist/task/task.service.js.map +1 -1
- package/dist/user/user.controller.d.ts +2 -2
- package/dist/user/user.service.d.ts +6 -6
- package/dist/webhook-integration/webhook-integration.service.d.ts +4 -0
- package/dist/webhook-integration/webhook-integration.service.d.ts.map +1 -1
- package/dist/webhook-integration/webhook-integration.service.js +184 -34
- package/dist/webhook-integration/webhook-integration.service.js.map +1 -1
- package/dist/webhook-integration/webhook-utils.d.ts +1 -0
- package/dist/webhook-integration/webhook-utils.d.ts.map +1 -1
- package/dist/webhook-integration/webhook-utils.js +38 -0
- package/dist/webhook-integration/webhook-utils.js.map +1 -1
- package/hedhog/data/menu.yaml +48 -4
- package/hedhog/data/route.yaml +133 -0
- package/hedhog/data/setting_group.yaml +45 -0
- package/hedhog/data/setting_subgroup.yaml +16 -0
- package/hedhog/frontend/app/account/components/mcp-tokens.tsx.ejs +285 -0
- package/hedhog/frontend/app/account/layout.tsx.ejs +32 -55
- package/hedhog/frontend/app/account/mcp-tokens/page.tsx.ejs +5 -0
- package/hedhog/frontend/app/integrations-webhooks/page.tsx.ejs +2098 -1835
- package/hedhog/frontend/app/mcp_chat/chat-components.tsx.ejs +595 -0
- package/hedhog/frontend/app/mcp_chat/chat-types.ts.ejs +16 -0
- package/hedhog/frontend/app/mcp_chat/page.tsx.ejs +554 -383
- package/hedhog/frontend/app/setting-list/page.tsx.ejs +649 -0
- package/hedhog/frontend/app/users/page.tsx.ejs +445 -203
- package/hedhog/frontend/app/users/user-sheet.tsx.ejs +16 -37
- package/hedhog/frontend/messages/en.json +241 -2
- package/hedhog/frontend/messages/pt.json +241 -2
- package/hedhog/table/mcp_api_key.yaml +30 -0
- package/hedhog/table/notification.yaml +72 -0
- package/hedhog/table/webhook_action_log.yaml +49 -0
- package/package.json +4 -4
- package/src/core.module.ts +3 -0
- package/src/index.ts +5 -0
- package/src/mcp/guards/mcp-auth.guard.ts +64 -32
- package/src/mcp/mcp-api-key.controller.ts +42 -0
- package/src/mcp/mcp-api-key.service.ts +66 -0
- package/src/mcp/mcp-registry.service.ts +75 -69
- package/src/mcp/mcp.module.ts +43 -36
- package/src/mcp-chat/mcp-chat.controller.ts +113 -60
- package/src/mcp-chat/mcp-chat.service.ts +494 -332
- package/src/notification/dto/create-notification.dto.ts +71 -0
- package/src/notification/dto/update-progress.dto.ts +16 -0
- package/src/notification/notification.controller.ts +71 -0
- package/src/notification/notification.module.ts +16 -0
- package/src/notification/notification.service.ts +124 -0
- package/src/setting/dto/update-setting-list.dto.ts +32 -0
- package/src/setting/setting.controller.ts +9 -0
- package/src/setting/setting.service.ts +91 -0
- package/src/task/task.service.ts +72 -0
- package/src/webhook-integration/webhook-integration.service.ts +934 -735
- package/src/webhook-integration/webhook-utils.ts +136 -79
|
@@ -1,79 +1,136 @@
|
|
|
1
|
-
import { createHash, randomBytes, randomUUID } from 'crypto';
|
|
2
|
-
import * as Handlebars from 'handlebars';
|
|
3
|
-
|
|
4
|
-
export function createPublicUuid() {
|
|
5
|
-
return randomUUID();
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function createPlainToken() {
|
|
9
|
-
return randomBytes(32).toString('hex');
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function hashToken(token: string) {
|
|
13
|
-
return createHash('sha256').update(token).digest('hex');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function renderTemplate(source: unknown, context: Record<string, any>) {
|
|
17
|
-
if (source === undefined || source === null) {
|
|
18
|
-
return source;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (typeof source === 'string') {
|
|
22
|
-
return Handlebars.compile(source)(context);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (Array.isArray(source)) {
|
|
26
|
-
return source.map((item) => renderTemplate(item, context));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (typeof source === 'object') {
|
|
30
|
-
return Object.fromEntries(
|
|
31
|
-
Object.entries(source as Record<string, unknown>).map(([key, value]) => [
|
|
32
|
-
key,
|
|
33
|
-
renderTemplate(value, context),
|
|
34
|
-
]),
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return source;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function summarizePayload(value: unknown) {
|
|
42
|
-
if (value === undefined || value === null) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
const serialized = JSON.stringify(value);
|
|
48
|
-
if (serialized.length <= 4000) {
|
|
49
|
-
return value as any;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return {
|
|
53
|
-
truncated: true,
|
|
54
|
-
preview: serialized.slice(0, 4000),
|
|
55
|
-
};
|
|
56
|
-
} catch {
|
|
57
|
-
return {
|
|
58
|
-
unsupported: true,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
1
|
+
import { createHash, randomBytes, randomUUID } from 'crypto';
|
|
2
|
+
import * as Handlebars from 'handlebars';
|
|
3
|
+
|
|
4
|
+
export function createPublicUuid() {
|
|
5
|
+
return randomUUID();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function createPlainToken() {
|
|
9
|
+
return randomBytes(32).toString('hex');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function hashToken(token: string) {
|
|
13
|
+
return createHash('sha256').update(token).digest('hex');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function renderTemplate(source: unknown, context: Record<string, any>) {
|
|
17
|
+
if (source === undefined || source === null) {
|
|
18
|
+
return source;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (typeof source === 'string') {
|
|
22
|
+
return Handlebars.compile(source)(context);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (Array.isArray(source)) {
|
|
26
|
+
return source.map((item) => renderTemplate(item, context));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (typeof source === 'object') {
|
|
30
|
+
return Object.fromEntries(
|
|
31
|
+
Object.entries(source as Record<string, unknown>).map(([key, value]) => [
|
|
32
|
+
key,
|
|
33
|
+
renderTemplate(value, context),
|
|
34
|
+
]),
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return source;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function summarizePayload(value: unknown) {
|
|
42
|
+
if (value === undefined || value === null) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
const serialized = JSON.stringify(value);
|
|
48
|
+
if (serialized.length <= 4000) {
|
|
49
|
+
return value as any;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
truncated: true,
|
|
54
|
+
preview: serialized.slice(0, 4000),
|
|
55
|
+
};
|
|
56
|
+
} catch {
|
|
57
|
+
return {
|
|
58
|
+
unsupported: true,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const SENSITIVE_KEY_PATTERN =
|
|
64
|
+
/(token|authorization|apikey|api_key|password|secret|credential|passwd)/i;
|
|
65
|
+
|
|
66
|
+
function maskString(value: string) {
|
|
67
|
+
if (!value) {
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (/^Bearer\s+/i.test(value)) {
|
|
72
|
+
return 'Bearer [REDACTED]';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (value.length <= 8) {
|
|
76
|
+
return '[REDACTED]';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return `${value.slice(0, 3)}***${value.slice(-2)}`;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function sanitizeSensitiveData(
|
|
83
|
+
value: unknown,
|
|
84
|
+
keyPath = '',
|
|
85
|
+
): unknown {
|
|
86
|
+
if (value === null || value === undefined) {
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (Array.isArray(value)) {
|
|
91
|
+
return value.map((item, index) =>
|
|
92
|
+
sanitizeSensitiveData(item, `${keyPath}[${index}]`),
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (typeof value === 'object') {
|
|
97
|
+
return Object.fromEntries(
|
|
98
|
+
Object.entries(value as Record<string, unknown>).map(([key, child]) => {
|
|
99
|
+
const nextPath = keyPath ? `${keyPath}.${key}` : key;
|
|
100
|
+
if (SENSITIVE_KEY_PATTERN.test(key)) {
|
|
101
|
+
if (typeof child === 'string') {
|
|
102
|
+
return [key, maskString(child)];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return [key, '[REDACTED]'];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return [key, sanitizeSensitiveData(child, nextPath)];
|
|
109
|
+
}),
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (typeof value === 'string' && SENSITIVE_KEY_PATTERN.test(keyPath)) {
|
|
114
|
+
return maskString(value);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return value;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function normalizeJsonObject(value: unknown) {
|
|
121
|
+
if (!value) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (typeof value === 'string') {
|
|
126
|
+
const trimmed = value.trim();
|
|
127
|
+
if (!trimmed) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return JSON.parse(trimmed);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return value;
|
|
135
|
+
}
|
|
136
|
+
|