@consilioweb/payload-support 1.1.0 → 2.0.0
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 +4 -0
- package/dist/components/TicketConversation/components/AISummaryPanel.cjs +22 -14
- package/dist/components/TicketConversation/components/AISummaryPanel.js +23 -16
- package/dist/components/TicketConversation/components/ActionPanels.cjs +5 -5
- package/dist/components/TicketConversation/components/ActionPanels.js +5 -5
- package/dist/components/TicketConversation/components/ClientBar.cjs +1 -1
- package/dist/components/TicketConversation/components/ClientBar.js +1 -1
- package/dist/components/TicketConversation/components/QuickActions.cjs +2 -2
- package/dist/components/TicketConversation/components/QuickActions.js +2 -2
- package/dist/components/TicketConversation/components/TicketHeader.cjs +1 -1
- package/dist/components/TicketConversation/components/TicketHeader.js +1 -1
- package/dist/components/TicketConversation/index.cjs +10 -10
- package/dist/components/TicketConversation/index.js +10 -10
- package/dist/index.cjs +710 -174
- package/dist/index.d.cts +165 -3
- package/dist/index.d.ts +165 -3
- package/dist/index.js +703 -176
- package/dist/styles/ChatView.module.scss +1 -1
- package/dist/styles/TicketDetail.module.scss +3 -3
- package/dist/styles/_tokens.scss +1 -1
- package/dist/styles/theme.css +6 -6
- package/dist/views/TicketingSettingsView/client.cjs +3 -3
- package/dist/views/TicketingSettingsView/client.js +3 -3
- package/package.json +9 -9
- package/src/__tests__/aiSummaryRendering.test.ts +21 -0
- package/src/__tests__/authResponses.test.ts +69 -0
- package/src/__tests__/capabilities.test.ts +71 -0
- package/src/__tests__/generateTrackingToken.test.ts +18 -4
- package/src/__tests__/integration/core-behaviors.test.ts +23 -0
- package/src/__tests__/rateLimiter.test.ts +60 -66
- package/src/__tests__/trackOpenEndpoint.test.ts +54 -0
- package/src/__tests__/webhookSecurity.test.ts +58 -0
- package/src/collections/PendingEmails.ts +2 -1
- package/src/collections/SupportClients.ts +43 -1
- package/src/collections/SupportCounters.ts +14 -0
- package/src/collections/SupportRateLimits.ts +20 -0
- package/src/collections/TicketMessages.ts +76 -0
- package/src/collections/Tickets.ts +183 -40
- package/src/collections/index.ts +2 -0
- package/src/components/TicketConversation/components/AISummaryPanel.tsx +26 -13
- package/src/components/TicketConversation/components/ActionPanels.tsx +5 -5
- package/src/components/TicketConversation/components/ClientBar.tsx +1 -1
- package/src/components/TicketConversation/components/QuickActions.tsx +2 -2
- package/src/components/TicketConversation/components/TicketHeader.tsx +1 -1
- package/src/components/TicketConversation/index.tsx +10 -10
- package/src/endpoints/admin-chat.ts +4 -4
- package/src/endpoints/ai-agent.ts +6 -1
- package/src/endpoints/ai.ts +10 -5
- package/src/endpoints/auth-2fa.ts +6 -7
- package/src/endpoints/auto-close.ts +2 -1
- package/src/endpoints/capabilities.ts +144 -0
- package/src/endpoints/channels.ts +2 -1
- package/src/endpoints/chat.ts +6 -6
- package/src/endpoints/chatbot.ts +4 -4
- package/src/endpoints/client-intelligence.ts +13 -4
- package/src/endpoints/import-conversation.ts +6 -5
- package/src/endpoints/index.ts +35 -14
- package/src/endpoints/invite-collaborator.ts +4 -4
- package/src/endpoints/login.ts +4 -5
- package/src/endpoints/oauth-google.ts +1 -1
- package/src/endpoints/process-digests.ts +2 -1
- package/src/endpoints/process-scheduled.ts +2 -1
- package/src/endpoints/process-snooze.ts +2 -1
- package/src/endpoints/resend-notification.ts +4 -4
- package/src/endpoints/send-reminder.ts +4 -4
- package/src/endpoints/ticket-synthesis.ts +17 -2
- package/src/endpoints/track-open.ts +44 -21
- package/src/endpoints/transfer-ticket.ts +4 -4
- package/src/index.ts +7 -0
- package/src/plugin.ts +16 -1
- package/src/portal/LiveChat.tsx +1 -1
- package/src/portal/auth/ChatWidget.tsx +4 -4
- package/src/portal/auth/ChatbotWidget.tsx +4 -4
- package/src/portal/auth/dashboard/DashboardClient.tsx +2 -2
- package/src/portal/auth/faq/FAQSearch.tsx +1 -1
- package/src/portal/auth/faq/page.tsx +2 -2
- package/src/portal/auth/profile/page.tsx +17 -17
- package/src/portal/auth/tickets/detail/CloseTicketButton.tsx +1 -1
- package/src/portal/auth/tickets/detail/MarkSolutionButton.tsx +1 -1
- package/src/portal/auth/tickets/detail/ReopenTicketButton.tsx +1 -1
- package/src/portal/auth/tickets/detail/SatisfactionForm.tsx +3 -3
- package/src/portal/auth/tickets/detail/TicketReplyForm.tsx +3 -3
- package/src/portal/auth/tickets/detail/page.tsx +5 -5
- package/src/portal/auth/tickets/new/page.tsx +8 -8
- package/src/portal/forgot-password/page.tsx +3 -3
- package/src/portal/layout.tsx +5 -2
- package/src/portal/login/page.tsx +7 -7
- package/src/portal/page.tsx +9 -9
- package/src/portal/register/page.tsx +4 -4
- package/src/portal/reset-password/page.tsx +3 -3
- package/src/styles/ChatView.module.scss +1 -1
- package/src/styles/TicketDetail.module.scss +3 -3
- package/src/styles/_tokens.scss +1 -1
- package/src/styles/theme.css +6 -6
- package/src/types.ts +71 -0
- package/src/utils/rateLimiter.ts +131 -38
- package/src/utils/slugs.ts +4 -0
- package/src/utils/webhookSecurity.ts +81 -0
- package/src/views/TicketingSettingsView/client.tsx +3 -3
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { createHash, timingSafeEqual } from 'crypto'
|
|
2
|
+
|
|
3
|
+
export interface InboundEmailLimits {
|
|
4
|
+
maxRequestBytes: number
|
|
5
|
+
maxAttachmentBytes: number
|
|
6
|
+
maxAttachments: number
|
|
7
|
+
maxSubjectLength: number
|
|
8
|
+
maxNameLength: number
|
|
9
|
+
maxEmailLength: number
|
|
10
|
+
maxBodyLength: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const DEFAULT_INBOUND_EMAIL_LIMITS: InboundEmailLimits = {
|
|
14
|
+
maxRequestBytes: 25 * 1024 * 1024,
|
|
15
|
+
maxAttachmentBytes: 10 * 1024 * 1024,
|
|
16
|
+
maxAttachments: 10,
|
|
17
|
+
maxSubjectLength: 1_000,
|
|
18
|
+
maxNameLength: 500,
|
|
19
|
+
maxEmailLength: 320,
|
|
20
|
+
maxBodyLength: 38_000,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface InboundAttachment {
|
|
24
|
+
filename?: string
|
|
25
|
+
size?: number
|
|
26
|
+
content?: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface InboundEmailInput {
|
|
30
|
+
senderEmail?: string
|
|
31
|
+
senderName?: string
|
|
32
|
+
recipientEmail?: string
|
|
33
|
+
cc?: string
|
|
34
|
+
subject?: string
|
|
35
|
+
body?: string
|
|
36
|
+
htmlBody?: string
|
|
37
|
+
attachments?: InboundAttachment[]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface InboundEmailValidationError {
|
|
41
|
+
code: 'request_too_large' | 'too_many_attachments' | 'attachment_too_large' | 'text_field_too_large'
|
|
42
|
+
status: 413
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function verifySecret(provided: string | null | undefined, expected: string | null | undefined): boolean {
|
|
46
|
+
if (!provided || !expected) return false
|
|
47
|
+
const providedDigest = createHash('sha256').update(provided).digest()
|
|
48
|
+
const expectedDigest = createHash('sha256').update(expected).digest()
|
|
49
|
+
return timingSafeEqual(providedDigest, expectedDigest)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function validateInboundEmailPayload(
|
|
53
|
+
input: InboundEmailInput,
|
|
54
|
+
contentLength?: number,
|
|
55
|
+
limits: InboundEmailLimits = DEFAULT_INBOUND_EMAIL_LIMITS,
|
|
56
|
+
): InboundEmailValidationError | null {
|
|
57
|
+
if (contentLength != null && contentLength > limits.maxRequestBytes) {
|
|
58
|
+
return { code: 'request_too_large', status: 413 }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const attachments = Array.isArray(input.attachments) ? input.attachments : []
|
|
62
|
+
if (attachments.length > limits.maxAttachments) {
|
|
63
|
+
return { code: 'too_many_attachments', status: 413 }
|
|
64
|
+
}
|
|
65
|
+
for (const attachment of attachments) {
|
|
66
|
+
const decodedSize = attachment.content ? Math.ceil(attachment.content.length * 0.75) : 0
|
|
67
|
+
if (Math.max(Number(attachment.size || 0), decodedSize) > limits.maxAttachmentBytes) {
|
|
68
|
+
return { code: 'attachment_too_large', status: 413 }
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const tooLong =
|
|
73
|
+
(input.subject?.length || 0) > limits.maxSubjectLength ||
|
|
74
|
+
(input.senderName?.length || 0) > limits.maxNameLength ||
|
|
75
|
+
(input.senderEmail?.length || 0) > limits.maxEmailLength ||
|
|
76
|
+
(input.recipientEmail?.length || 0) > limits.maxEmailLength ||
|
|
77
|
+
(input.cc?.length || 0) > limits.maxEmailLength ||
|
|
78
|
+
(input.body?.length || 0) > limits.maxBodyLength ||
|
|
79
|
+
(input.htmlBody?.length || 0) > limits.maxBodyLength
|
|
80
|
+
return tooLong ? { code: 'text_field_too_large', status: 413 } : null
|
|
81
|
+
}
|
|
@@ -206,7 +206,7 @@ function getCategories(t: (key: string) => string) {
|
|
|
206
206
|
{ key: 'core', label: t('settingsView.categories.core'), color: V.blue },
|
|
207
207
|
{ key: 'communication', label: t('settingsView.categories.communication'), color: V.green },
|
|
208
208
|
{ key: 'productivity', label: t('settingsView.categories.productivity'), color: V.amber },
|
|
209
|
-
{ key: 'advanced', label: t('settingsView.categories.advanced'), color: '#
|
|
209
|
+
{ key: 'advanced', label: t('settingsView.categories.advanced'), color: '#17807c' },
|
|
210
210
|
]
|
|
211
211
|
}
|
|
212
212
|
|
|
@@ -532,7 +532,7 @@ export const TicketingSettingsClient: React.FC = () => {
|
|
|
532
532
|
<CollapsibleSection
|
|
533
533
|
title={t('settingsView.aiTitle')}
|
|
534
534
|
icon={<Bot size={16} />}
|
|
535
|
-
color="#
|
|
535
|
+
color="#17807c"
|
|
536
536
|
defaultOpen={false}
|
|
537
537
|
badge={
|
|
538
538
|
features.ai
|
|
@@ -604,7 +604,7 @@ export const TicketingSettingsClient: React.FC = () => {
|
|
|
604
604
|
<Toggle
|
|
605
605
|
checked={settings.ai[item.key]}
|
|
606
606
|
onChange={() => updateAI(item.key, !settings.ai[item.key])}
|
|
607
|
-
color="#
|
|
607
|
+
color="#17807c"
|
|
608
608
|
size="sm"
|
|
609
609
|
/>
|
|
610
610
|
<div style={{ flex: 1 }}>
|