@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.
Files changed (126) hide show
  1. package/dist/auth/auth.controller.d.ts +3 -3
  2. package/dist/auth/auth.service.d.ts +8 -8
  3. package/dist/core.module.d.ts.map +1 -1
  4. package/dist/core.module.js +3 -0
  5. package/dist/core.module.js.map +1 -1
  6. package/dist/index.d.ts +3 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +4 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/mcp/guards/mcp-auth.guard.d.ts +6 -1
  11. package/dist/mcp/guards/mcp-auth.guard.d.ts.map +1 -1
  12. package/dist/mcp/guards/mcp-auth.guard.js +29 -2
  13. package/dist/mcp/guards/mcp-auth.guard.js.map +1 -1
  14. package/dist/mcp/mcp-api-key.controller.d.ts +32 -0
  15. package/dist/mcp/mcp-api-key.controller.d.ts.map +1 -0
  16. package/dist/mcp/mcp-api-key.controller.js +64 -0
  17. package/dist/mcp/mcp-api-key.controller.js.map +1 -0
  18. package/dist/mcp/mcp-api-key.service.d.ts +27 -0
  19. package/dist/mcp/mcp-api-key.service.d.ts.map +1 -0
  20. package/dist/mcp/mcp-api-key.service.js +74 -0
  21. package/dist/mcp/mcp-api-key.service.js.map +1 -0
  22. package/dist/mcp/mcp-registry.service.d.ts +1 -2
  23. package/dist/mcp/mcp-registry.service.d.ts.map +1 -1
  24. package/dist/mcp/mcp-registry.service.js +6 -2
  25. package/dist/mcp/mcp-registry.service.js.map +1 -1
  26. package/dist/mcp/mcp.module.d.ts.map +1 -1
  27. package/dist/mcp/mcp.module.js +8 -1
  28. package/dist/mcp/mcp.module.js.map +1 -1
  29. package/dist/mcp-chat/mcp-chat.controller.d.ts +4 -0
  30. package/dist/mcp-chat/mcp-chat.controller.d.ts.map +1 -1
  31. package/dist/mcp-chat/mcp-chat.controller.js +46 -0
  32. package/dist/mcp-chat/mcp-chat.controller.js.map +1 -1
  33. package/dist/mcp-chat/mcp-chat.service.d.ts +6 -1
  34. package/dist/mcp-chat/mcp-chat.service.d.ts.map +1 -1
  35. package/dist/mcp-chat/mcp-chat.service.js +125 -17
  36. package/dist/mcp-chat/mcp-chat.service.js.map +1 -1
  37. package/dist/notification/dto/create-notification.dto.d.ts +26 -0
  38. package/dist/notification/dto/create-notification.dto.d.ts.map +1 -0
  39. package/dist/notification/dto/create-notification.dto.js +86 -0
  40. package/dist/notification/dto/create-notification.dto.js.map +1 -0
  41. package/dist/notification/dto/update-progress.dto.d.ts +6 -0
  42. package/dist/notification/dto/update-progress.dto.d.ts.map +1 -0
  43. package/dist/notification/dto/update-progress.dto.js +33 -0
  44. package/dist/notification/dto/update-progress.dto.js.map +1 -0
  45. package/dist/notification/notification.controller.d.ts +108 -0
  46. package/dist/notification/notification.controller.d.ts.map +1 -0
  47. package/dist/notification/notification.controller.js +118 -0
  48. package/dist/notification/notification.controller.js.map +1 -0
  49. package/dist/notification/notification.module.d.ts +3 -0
  50. package/dist/notification/notification.module.d.ts.map +1 -0
  51. package/dist/notification/notification.module.js +29 -0
  52. package/dist/notification/notification.module.js.map +1 -0
  53. package/dist/notification/notification.service.d.ts +98 -0
  54. package/dist/notification/notification.service.d.ts.map +1 -0
  55. package/dist/notification/notification.service.js +123 -0
  56. package/dist/notification/notification.service.js.map +1 -0
  57. package/dist/profile/profile.controller.d.ts +1 -1
  58. package/dist/profile/profile.service.d.ts +1 -1
  59. package/dist/session/session.controller.d.ts +1 -1
  60. package/dist/session/session.service.d.ts +3 -3
  61. package/dist/setting/dto/update-setting-list.dto.d.ts +9 -0
  62. package/dist/setting/dto/update-setting-list.dto.d.ts.map +1 -0
  63. package/dist/setting/dto/update-setting-list.dto.js +44 -0
  64. package/dist/setting/dto/update-setting-list.dto.js.map +1 -0
  65. package/dist/setting/setting.controller.d.ts +19 -0
  66. package/dist/setting/setting.controller.d.ts.map +1 -1
  67. package/dist/setting/setting.controller.js +12 -0
  68. package/dist/setting/setting.controller.js.map +1 -1
  69. package/dist/setting/setting.service.d.ts +19 -0
  70. package/dist/setting/setting.service.d.ts.map +1 -1
  71. package/dist/setting/setting.service.js +79 -0
  72. package/dist/setting/setting.service.js.map +1 -1
  73. package/dist/task/task.service.d.ts +12 -0
  74. package/dist/task/task.service.d.ts.map +1 -1
  75. package/dist/task/task.service.js +60 -0
  76. package/dist/task/task.service.js.map +1 -1
  77. package/dist/user/user.controller.d.ts +2 -2
  78. package/dist/user/user.service.d.ts +6 -6
  79. package/dist/webhook-integration/webhook-integration.service.d.ts +4 -0
  80. package/dist/webhook-integration/webhook-integration.service.d.ts.map +1 -1
  81. package/dist/webhook-integration/webhook-integration.service.js +184 -34
  82. package/dist/webhook-integration/webhook-integration.service.js.map +1 -1
  83. package/dist/webhook-integration/webhook-utils.d.ts +1 -0
  84. package/dist/webhook-integration/webhook-utils.d.ts.map +1 -1
  85. package/dist/webhook-integration/webhook-utils.js +38 -0
  86. package/dist/webhook-integration/webhook-utils.js.map +1 -1
  87. package/hedhog/data/menu.yaml +48 -4
  88. package/hedhog/data/route.yaml +133 -0
  89. package/hedhog/data/setting_group.yaml +45 -0
  90. package/hedhog/data/setting_subgroup.yaml +16 -0
  91. package/hedhog/frontend/app/account/components/mcp-tokens.tsx.ejs +285 -0
  92. package/hedhog/frontend/app/account/layout.tsx.ejs +32 -55
  93. package/hedhog/frontend/app/account/mcp-tokens/page.tsx.ejs +5 -0
  94. package/hedhog/frontend/app/integrations-webhooks/page.tsx.ejs +2098 -1835
  95. package/hedhog/frontend/app/mcp_chat/chat-components.tsx.ejs +595 -0
  96. package/hedhog/frontend/app/mcp_chat/chat-types.ts.ejs +16 -0
  97. package/hedhog/frontend/app/mcp_chat/page.tsx.ejs +554 -383
  98. package/hedhog/frontend/app/setting-list/page.tsx.ejs +649 -0
  99. package/hedhog/frontend/app/users/page.tsx.ejs +445 -203
  100. package/hedhog/frontend/app/users/user-sheet.tsx.ejs +16 -37
  101. package/hedhog/frontend/messages/en.json +241 -2
  102. package/hedhog/frontend/messages/pt.json +241 -2
  103. package/hedhog/table/mcp_api_key.yaml +30 -0
  104. package/hedhog/table/notification.yaml +72 -0
  105. package/hedhog/table/webhook_action_log.yaml +49 -0
  106. package/package.json +4 -4
  107. package/src/core.module.ts +3 -0
  108. package/src/index.ts +5 -0
  109. package/src/mcp/guards/mcp-auth.guard.ts +64 -32
  110. package/src/mcp/mcp-api-key.controller.ts +42 -0
  111. package/src/mcp/mcp-api-key.service.ts +66 -0
  112. package/src/mcp/mcp-registry.service.ts +75 -69
  113. package/src/mcp/mcp.module.ts +43 -36
  114. package/src/mcp-chat/mcp-chat.controller.ts +113 -60
  115. package/src/mcp-chat/mcp-chat.service.ts +494 -332
  116. package/src/notification/dto/create-notification.dto.ts +71 -0
  117. package/src/notification/dto/update-progress.dto.ts +16 -0
  118. package/src/notification/notification.controller.ts +71 -0
  119. package/src/notification/notification.module.ts +16 -0
  120. package/src/notification/notification.service.ts +124 -0
  121. package/src/setting/dto/update-setting-list.dto.ts +32 -0
  122. package/src/setting/setting.controller.ts +9 -0
  123. package/src/setting/setting.service.ts +91 -0
  124. package/src/task/task.service.ts +72 -0
  125. package/src/webhook-integration/webhook-integration.service.ts +934 -735
  126. 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
- export function normalizeJsonObject(value: unknown) {
64
- if (!value) {
65
- return null;
66
- }
67
-
68
- if (typeof value === 'string') {
69
- const trimmed = value.trim();
70
- if (!trimmed) {
71
- return null;
72
- }
73
-
74
- return JSON.parse(trimmed);
75
- }
76
-
77
- return value;
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
+