@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.
Files changed (99) hide show
  1. package/README.md +4 -0
  2. package/dist/components/TicketConversation/components/AISummaryPanel.cjs +22 -14
  3. package/dist/components/TicketConversation/components/AISummaryPanel.js +23 -16
  4. package/dist/components/TicketConversation/components/ActionPanels.cjs +5 -5
  5. package/dist/components/TicketConversation/components/ActionPanels.js +5 -5
  6. package/dist/components/TicketConversation/components/ClientBar.cjs +1 -1
  7. package/dist/components/TicketConversation/components/ClientBar.js +1 -1
  8. package/dist/components/TicketConversation/components/QuickActions.cjs +2 -2
  9. package/dist/components/TicketConversation/components/QuickActions.js +2 -2
  10. package/dist/components/TicketConversation/components/TicketHeader.cjs +1 -1
  11. package/dist/components/TicketConversation/components/TicketHeader.js +1 -1
  12. package/dist/components/TicketConversation/index.cjs +10 -10
  13. package/dist/components/TicketConversation/index.js +10 -10
  14. package/dist/index.cjs +710 -174
  15. package/dist/index.d.cts +165 -3
  16. package/dist/index.d.ts +165 -3
  17. package/dist/index.js +703 -176
  18. package/dist/styles/ChatView.module.scss +1 -1
  19. package/dist/styles/TicketDetail.module.scss +3 -3
  20. package/dist/styles/_tokens.scss +1 -1
  21. package/dist/styles/theme.css +6 -6
  22. package/dist/views/TicketingSettingsView/client.cjs +3 -3
  23. package/dist/views/TicketingSettingsView/client.js +3 -3
  24. package/package.json +9 -9
  25. package/src/__tests__/aiSummaryRendering.test.ts +21 -0
  26. package/src/__tests__/authResponses.test.ts +69 -0
  27. package/src/__tests__/capabilities.test.ts +71 -0
  28. package/src/__tests__/generateTrackingToken.test.ts +18 -4
  29. package/src/__tests__/integration/core-behaviors.test.ts +23 -0
  30. package/src/__tests__/rateLimiter.test.ts +60 -66
  31. package/src/__tests__/trackOpenEndpoint.test.ts +54 -0
  32. package/src/__tests__/webhookSecurity.test.ts +58 -0
  33. package/src/collections/PendingEmails.ts +2 -1
  34. package/src/collections/SupportClients.ts +43 -1
  35. package/src/collections/SupportCounters.ts +14 -0
  36. package/src/collections/SupportRateLimits.ts +20 -0
  37. package/src/collections/TicketMessages.ts +76 -0
  38. package/src/collections/Tickets.ts +183 -40
  39. package/src/collections/index.ts +2 -0
  40. package/src/components/TicketConversation/components/AISummaryPanel.tsx +26 -13
  41. package/src/components/TicketConversation/components/ActionPanels.tsx +5 -5
  42. package/src/components/TicketConversation/components/ClientBar.tsx +1 -1
  43. package/src/components/TicketConversation/components/QuickActions.tsx +2 -2
  44. package/src/components/TicketConversation/components/TicketHeader.tsx +1 -1
  45. package/src/components/TicketConversation/index.tsx +10 -10
  46. package/src/endpoints/admin-chat.ts +4 -4
  47. package/src/endpoints/ai-agent.ts +6 -1
  48. package/src/endpoints/ai.ts +10 -5
  49. package/src/endpoints/auth-2fa.ts +6 -7
  50. package/src/endpoints/auto-close.ts +2 -1
  51. package/src/endpoints/capabilities.ts +144 -0
  52. package/src/endpoints/channels.ts +2 -1
  53. package/src/endpoints/chat.ts +6 -6
  54. package/src/endpoints/chatbot.ts +4 -4
  55. package/src/endpoints/client-intelligence.ts +13 -4
  56. package/src/endpoints/import-conversation.ts +6 -5
  57. package/src/endpoints/index.ts +35 -14
  58. package/src/endpoints/invite-collaborator.ts +4 -4
  59. package/src/endpoints/login.ts +4 -5
  60. package/src/endpoints/oauth-google.ts +1 -1
  61. package/src/endpoints/process-digests.ts +2 -1
  62. package/src/endpoints/process-scheduled.ts +2 -1
  63. package/src/endpoints/process-snooze.ts +2 -1
  64. package/src/endpoints/resend-notification.ts +4 -4
  65. package/src/endpoints/send-reminder.ts +4 -4
  66. package/src/endpoints/ticket-synthesis.ts +17 -2
  67. package/src/endpoints/track-open.ts +44 -21
  68. package/src/endpoints/transfer-ticket.ts +4 -4
  69. package/src/index.ts +7 -0
  70. package/src/plugin.ts +16 -1
  71. package/src/portal/LiveChat.tsx +1 -1
  72. package/src/portal/auth/ChatWidget.tsx +4 -4
  73. package/src/portal/auth/ChatbotWidget.tsx +4 -4
  74. package/src/portal/auth/dashboard/DashboardClient.tsx +2 -2
  75. package/src/portal/auth/faq/FAQSearch.tsx +1 -1
  76. package/src/portal/auth/faq/page.tsx +2 -2
  77. package/src/portal/auth/profile/page.tsx +17 -17
  78. package/src/portal/auth/tickets/detail/CloseTicketButton.tsx +1 -1
  79. package/src/portal/auth/tickets/detail/MarkSolutionButton.tsx +1 -1
  80. package/src/portal/auth/tickets/detail/ReopenTicketButton.tsx +1 -1
  81. package/src/portal/auth/tickets/detail/SatisfactionForm.tsx +3 -3
  82. package/src/portal/auth/tickets/detail/TicketReplyForm.tsx +3 -3
  83. package/src/portal/auth/tickets/detail/page.tsx +5 -5
  84. package/src/portal/auth/tickets/new/page.tsx +8 -8
  85. package/src/portal/forgot-password/page.tsx +3 -3
  86. package/src/portal/layout.tsx +5 -2
  87. package/src/portal/login/page.tsx +7 -7
  88. package/src/portal/page.tsx +9 -9
  89. package/src/portal/register/page.tsx +4 -4
  90. package/src/portal/reset-password/page.tsx +3 -3
  91. package/src/styles/ChatView.module.scss +1 -1
  92. package/src/styles/TicketDetail.module.scss +3 -3
  93. package/src/styles/_tokens.scss +1 -1
  94. package/src/styles/theme.css +6 -6
  95. package/src/types.ts +71 -0
  96. package/src/utils/rateLimiter.ts +131 -38
  97. package/src/utils/slugs.ts +4 -0
  98. package/src/utils/webhookSecurity.ts +81 -0
  99. 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: '#7c3aed' },
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="#7c3aed"
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="#7c3aed"
607
+ color="#17807c"
608
608
  size="sm"
609
609
  />
610
610
  <div style={{ flex: 1 }}>