@cosmicdrift/kumiko-bundled-features 0.405.0 → 0.409.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 (337) hide show
  1. package/dist/account-security/feature.js +9 -1
  2. package/dist/admin-shell/feature.d.ts +3 -0
  3. package/dist/admin-shell/feature.js +1 -1
  4. package/dist/agent-tools/agent-manifest.js +1 -0
  5. package/dist/agent-tools/tool-catalog.js +1 -0
  6. package/dist/agent-tools/types.d.ts +4 -1
  7. package/dist/audit/event-classification.js +1 -0
  8. package/dist/auth-email-password/bootstrap.js +1 -0
  9. package/dist/auth-email-password/errors.js +16 -41
  10. package/dist/auth-email-password/web/auth-client.d.ts +8 -32
  11. package/dist/auth-email-password/web/auth-client.js +18 -52
  12. package/dist/auth-email-password/web/auth-redirect.js +2 -2
  13. package/dist/auth-email-password/web/confirm-account-unlock-screen.d.ts +2 -2
  14. package/dist/auth-email-password/web/confirm-account-unlock-screen.js +14 -35
  15. package/dist/auth-email-password/web/index.d.ts +1 -0
  16. package/dist/auth-email-password/web/index.js +1 -0
  17. package/dist/auth-email-password/web/read-path-param.d.ts +1 -0
  18. package/dist/auth-email-password/web/read-path-param.js +4 -0
  19. package/dist/auth-email-password/web/return-path.js +2 -2
  20. package/dist/auth-email-password/web/token-confirm-screen.d.ts +20 -0
  21. package/dist/auth-email-password/web/token-confirm-screen.js +38 -0
  22. package/dist/auth-email-password/web/verify-email-screen.d.ts +2 -2
  23. package/dist/auth-email-password/web/verify-email-screen.js +14 -37
  24. package/dist/auth-foundation/boot-checks.js +24 -12
  25. package/dist/auth-foundation/boot-rules.d.ts +27 -0
  26. package/dist/auth-foundation/boot-rules.js +27 -0
  27. package/dist/auth-mfa/errors.d.ts +1 -1
  28. package/dist/auth-mfa/errors.js +11 -24
  29. package/dist/auth-mfa/feature-exports.js +6 -45
  30. package/dist/auth-mfa/feature.js +7 -18
  31. package/dist/auth-mfa/web/mfa-client.js +11 -25
  32. package/dist/billing-foundation/consumer-protection/termination-notify.js +1 -0
  33. package/dist/billing-foundation/web/plan-price.js +7 -8
  34. package/dist/cap-counter/stock-cap-guard.js +1 -0
  35. package/dist/channel-in-app/constants.d.ts +1 -0
  36. package/dist/channel-in-app/feature.js +2 -0
  37. package/dist/channel-in-app/handlers/read-state-by-keys.query.d.ts +9 -0
  38. package/dist/channel-in-app/handlers/read-state-by-keys.query.js +21 -0
  39. package/dist/channel-in-app/in-app-channel.js +1 -0
  40. package/dist/channel-in-app/tables.js +5 -1
  41. package/dist/contact/challenge.d.ts +14 -0
  42. package/dist/contact/challenge.js +30 -0
  43. package/dist/contact/client/contact-client-source.d.ts +1 -0
  44. package/dist/contact/client/contact-client-source.js +203 -0
  45. package/dist/contact/entity.d.ts +777 -0
  46. package/dist/contact/entity.js +145 -0
  47. package/dist/contact/feature.d.ts +3 -0
  48. package/dist/contact/feature.js +130 -0
  49. package/dist/contact/handlers/access.d.ts +7 -0
  50. package/dist/contact/handlers/access.js +9 -0
  51. package/dist/contact/handlers/attempts.d.ts +14 -0
  52. package/dist/contact/handlers/attempts.js +54 -0
  53. package/dist/contact/handlers/challenge.query.d.ts +9 -0
  54. package/dist/contact/handlers/challenge.query.js +35 -0
  55. package/dist/contact/handlers/forward-request.write.d.ts +9 -0
  56. package/dist/contact/handlers/forward-request.write.js +61 -0
  57. package/dist/contact/handlers/mark-done.write.d.ts +7 -0
  58. package/dist/contact/handlers/mark-done.write.js +30 -0
  59. package/dist/contact/handlers/notify-reporter-in-app.write.d.ts +10 -0
  60. package/dist/contact/handlers/notify-reporter-in-app.write.js +36 -0
  61. package/dist/contact/handlers/open-count.d.ts +2 -0
  62. package/dist/contact/handlers/open-count.js +11 -0
  63. package/dist/contact/handlers/open-count.query.d.ts +3 -0
  64. package/dist/contact/handlers/open-count.query.js +13 -0
  65. package/dist/contact/handlers/replies.query.d.ts +11 -0
  66. package/dist/contact/handlers/replies.query.js +28 -0
  67. package/dist/contact/handlers/reply.write.d.ts +12 -0
  68. package/dist/contact/handlers/reply.write.js +118 -0
  69. package/dist/contact/handlers/report.write.d.ts +16 -0
  70. package/dist/contact/handlers/report.write.js +90 -0
  71. package/dist/contact/handlers/request-delivery.query.d.ts +16 -0
  72. package/dist/contact/handlers/request-delivery.query.js +85 -0
  73. package/dist/contact/handlers/request-detail.query.d.ts +41 -0
  74. package/dist/contact/handlers/request-detail.query.js +32 -0
  75. package/dist/contact/handlers/request-list.query.d.ts +2 -0
  76. package/dist/contact/handlers/request-list.query.js +9 -0
  77. package/dist/contact/handlers/send-reply-mail.write.d.ts +8 -0
  78. package/dist/contact/handlers/send-reply-mail.write.js +82 -0
  79. package/dist/contact/handlers/send-test.write.d.ts +5 -0
  80. package/dist/contact/handlers/send-test.write.js +36 -0
  81. package/dist/contact/handlers/submit.write.d.ts +20 -0
  82. package/dist/contact/handlers/submit.write.js +137 -0
  83. package/dist/contact/handlers/take-over-uploads.d.ts +9 -0
  84. package/dist/contact/handlers/take-over-uploads.js +33 -0
  85. package/dist/contact/i18n.d.ts +6 -0
  86. package/dist/contact/i18n.js +186 -0
  87. package/dist/contact/index.d.ts +5 -0
  88. package/dist/contact/index.js +4 -0
  89. package/dist/contact/lib.d.ts +101 -0
  90. package/dist/contact/lib.js +109 -0
  91. package/dist/contact/mail.d.ts +91 -0
  92. package/dist/contact/mail.js +279 -0
  93. package/dist/contact/options.d.ts +51 -0
  94. package/dist/contact/options.js +32 -0
  95. package/dist/contact/panels.d.ts +2 -0
  96. package/dist/contact/panels.js +21 -0
  97. package/dist/contact/payloads.d.ts +56 -0
  98. package/dist/contact/payloads.js +82 -0
  99. package/dist/contact/pow.d.ts +6 -0
  100. package/dist/contact/pow.js +19 -0
  101. package/dist/contact/screens.d.ts +5 -0
  102. package/dist/contact/screens.js +464 -0
  103. package/dist/contact/subject.d.ts +1 -0
  104. package/dist/contact/subject.js +13 -0
  105. package/dist/contact/user-agent.d.ts +1 -0
  106. package/dist/contact/user-agent.js +35 -0
  107. package/dist/contact/user-data-hooks.d.ts +3 -0
  108. package/dist/contact/user-data-hooks.js +129 -0
  109. package/dist/contact/web/constants.d.ts +127 -0
  110. package/dist/contact/web/constants.js +126 -0
  111. package/dist/contact/web/index.d.ts +1 -0
  112. package/dist/contact/web/index.js +1 -0
  113. package/dist/crypto-shredding/handlers/forget-subject.write.js +5 -13
  114. package/dist/data-retention/feature.js +16 -2
  115. package/dist/data-retention/index.d.ts +1 -0
  116. package/dist/data-retention/index.js +1 -0
  117. package/dist/data-retention/run-retention-cleanup.d.ts +14 -2
  118. package/dist/data-retention/run-retention-cleanup.js +102 -36
  119. package/dist/data-retention/tenant-destruction-hold.d.ts +23 -0
  120. package/dist/data-retention/tenant-destruction-hold.js +132 -0
  121. package/dist/delivery/address-opt-out.js +1 -0
  122. package/dist/delivery/channel-context.d.ts +1 -1
  123. package/dist/delivery/channel-context.js +2 -1
  124. package/dist/delivery/delivery-service.js +18 -8
  125. package/dist/delivery/events.d.ts +1 -0
  126. package/dist/delivery/events.js +2 -0
  127. package/dist/delivery/feature.js +3 -0
  128. package/dist/delivery/handlers/attempts-by-keys.query.d.ts +15 -0
  129. package/dist/delivery/handlers/attempts-by-keys.query.js +35 -0
  130. package/dist/delivery/handlers/log.query.d.ts +1 -0
  131. package/dist/delivery/handlers/log.query.js +1 -1
  132. package/dist/delivery/jobs.js +5 -2
  133. package/dist/delivery/tables.js +12 -2
  134. package/dist/delivery/types.d.ts +2 -0
  135. package/dist/delivery/unsubscribe-page.js +2 -0
  136. package/dist/delivery/web/delivery-channel-cell.js +1 -1
  137. package/dist/delivery/web/delivery-error-cell.js +1 -1
  138. package/dist/delivery/web/delivery-status-cell.js +1 -1
  139. package/dist/delivery/web/delivery-time-cell.js +3 -2
  140. package/dist/delivery/web/delivery-type-cell.js +1 -1
  141. package/dist/delivery/web/public-names.d.ts +1 -0
  142. package/dist/delivery/web/public-names.js +1 -0
  143. package/dist/document-ingest-foundation/boot-checks.js +19 -11
  144. package/dist/document-ingest-foundation/boot-rules.d.ts +17 -0
  145. package/dist/document-ingest-foundation/boot-rules.js +17 -0
  146. package/dist/document-ingest-foundation/events.d.ts +8 -0
  147. package/dist/document-ingest-foundation/events.js +12 -0
  148. package/dist/document-ingest-foundation/feature.js +30 -2
  149. package/dist/document-ingest-foundation/index.d.ts +3 -1
  150. package/dist/document-ingest-foundation/index.js +3 -1
  151. package/dist/document-ingest-foundation/report-ingest-progress.d.ts +14 -0
  152. package/dist/document-ingest-foundation/report-ingest-progress.js +20 -0
  153. package/dist/document-ingest-foundation/tables.d.ts +3 -0
  154. package/dist/document-ingest-foundation/tables.js +26 -0
  155. package/dist/files-tenant-data/hooks.js +4 -1
  156. package/dist/folders/web/folder-manager.js +3 -10
  157. package/dist/folders/web/folder-section.js +1 -1
  158. package/dist/form-draft-user-data/index.js +4 -1
  159. package/dist/inbound-mail-foundation/entities.d.ts +3 -0
  160. package/dist/inbound-mail-foundation/entities.js +2 -0
  161. package/dist/inbound-mail-foundation/events.d.ts +2 -0
  162. package/dist/inbound-mail-foundation/events.js +2 -0
  163. package/dist/inbound-mail-foundation/feature.js +6 -6
  164. package/dist/inbound-mail-foundation/handlers/attach-message-content.write.js +3 -1
  165. package/dist/inbound-mail-foundation/handlers/ingest-message.write.js +5 -0
  166. package/dist/inbound-mail-foundation/handlers/list-messages.query.js +4 -2
  167. package/dist/inbound-mail-foundation/handlers/message-content.d.ts +1 -0
  168. package/dist/inbound-mail-foundation/handlers/message-content.js +8 -0
  169. package/dist/inbound-mail-foundation/handlers/message-content.query.d.ts +2 -0
  170. package/dist/inbound-mail-foundation/handlers/message-content.query.js +1 -0
  171. package/dist/inbound-mail-foundation/projection.d.ts +3 -0
  172. package/dist/inbound-mail-foundation/projection.js +2 -0
  173. package/dist/inbound-mail-foundation/sanitize-inbound-html.d.ts +2 -0
  174. package/dist/inbound-mail-foundation/sanitize-inbound-html.js +135 -0
  175. package/dist/inbound-mail-foundation/types.js +1 -0
  176. package/dist/jobs/job-run-logger.js +16 -20
  177. package/dist/ledger/handlers/reports.query.js +25 -27
  178. package/dist/ledger/recurring.js +1 -0
  179. package/dist/notes-history/web/notes-section.js +3 -2
  180. package/dist/personal-access-tokens/feature.js +5 -18
  181. package/dist/personal-access-tokens/handlers/create.write.js +2 -5
  182. package/dist/secrets/handlers/delete.write.d.ts +4 -0
  183. package/dist/secrets/handlers/delete.write.js +9 -4
  184. package/dist/secrets/handlers/list.query.d.ts +6 -1
  185. package/dist/secrets/handlers/list.query.js +7 -3
  186. package/dist/secrets/handlers/set.write.d.ts +4 -0
  187. package/dist/secrets/handlers/set.write.js +10 -4
  188. package/dist/secrets/secret-scope.d.ts +17 -0
  189. package/dist/secrets/secret-scope.js +18 -0
  190. package/dist/sessions/feature.d.ts +3 -0
  191. package/dist/sessions/feature.js +13 -19
  192. package/dist/sessions/handlers/last-activity-probe.query.d.ts +7 -0
  193. package/dist/sessions/handlers/last-activity-probe.query.js +40 -0
  194. package/dist/sessions/handlers/last-activity-probe.route.d.ts +2 -0
  195. package/dist/sessions/handlers/last-activity-probe.route.js +30 -0
  196. package/dist/sessions/screens.js +1 -0
  197. package/dist/sessions/session-callbacks.d.ts +2 -0
  198. package/dist/sessions/session-callbacks.js +9 -7
  199. package/dist/sessions/web/i18n.js +4 -1
  200. package/dist/shared/assert-billing-live.d.ts +2 -0
  201. package/dist/shared/assert-billing-live.js +7 -0
  202. package/dist/shared/collect-extension-options.d.ts +1 -0
  203. package/dist/shared/collect-extension-options.js +8 -0
  204. package/dist/shared/index.d.ts +7 -1
  205. package/dist/shared/index.js +7 -1
  206. package/dist/shared/late-bound-slot.d.ts +5 -0
  207. package/dist/shared/late-bound-slot.js +13 -0
  208. package/dist/shared/mail-locale-templates.d.ts +1 -0
  209. package/dist/shared/mail-locale-templates.js +1 -1
  210. package/dist/shared/price-env-shape.d.ts +11 -0
  211. package/dist/shared/price-env-shape.js +15 -0
  212. package/dist/shared/purge-row-file-refs.d.ts +1 -0
  213. package/dist/shared/purge-row-file-refs.js +1 -1
  214. package/dist/shared/read-feature-export-fn.d.ts +2 -0
  215. package/dist/shared/read-feature-export-fn.js +11 -0
  216. package/dist/shared/signup-handover.js +3 -5
  217. package/dist/shared/tenant-destruction-hold.d.ts +23 -0
  218. package/dist/shared/tenant-destruction-hold.js +15 -0
  219. package/dist/shared/unprocessable.d.ts +4 -0
  220. package/dist/shared/unprocessable.js +4 -0
  221. package/dist/shared/web/index.d.ts +3 -0
  222. package/dist/shared/web/index.js +3 -0
  223. package/dist/subscription-paddle/feature.d.ts +1 -5
  224. package/dist/subscription-paddle/feature.js +7 -9
  225. package/dist/subscription-paddle/runtime.js +3 -7
  226. package/dist/subscription-stripe/feature.d.ts +1 -5
  227. package/dist/subscription-stripe/feature.js +7 -9
  228. package/dist/subscription-stripe/runtime.js +3 -7
  229. package/dist/tags/entity.js +1 -0
  230. package/dist/tags/web/tag-chip.d.ts +7 -0
  231. package/dist/tags/web/tag-chip.js +4 -0
  232. package/dist/tags/web/tag-filter.js +2 -5
  233. package/dist/tags/web/tag-manager.js +1 -1
  234. package/dist/tags/web/tag-section.js +3 -6
  235. package/dist/tags/web/tags-cell.js +2 -5
  236. package/dist/template-resolver/compile-document-body.js +12 -17
  237. package/dist/template-resolver/handlers/by-tenant.query.js +3 -1
  238. package/dist/template-resolver/handlers/discard-draft.write.js +1 -0
  239. package/dist/template-resolver/handlers/overview.query.js +3 -1
  240. package/dist/template-resolver/handlers/send-test.write.js +2 -4
  241. package/dist/template-resolver/handlers/toggle-status.write.js +3 -0
  242. package/dist/template-resolver/linked-resources.js +6 -5
  243. package/dist/template-resolver/store-template-resource.js +5 -10
  244. package/dist/template-resolver/web/document-images.js +6 -6
  245. package/dist/template-resolver/web/document-insert-fields.js +22 -4
  246. package/dist/template-resolver/web/document-schema.js +11 -12
  247. package/dist/template-resolver/web/tiptap-attribute-parse-rule.d.ts +15 -0
  248. package/dist/template-resolver/web/tiptap-attribute-parse-rule.js +11 -0
  249. package/dist/tenant/i18n.js +3 -0
  250. package/dist/tenant/schema/tenant.d.ts +9 -7
  251. package/dist/tenant/schema/tenant.js +1 -0
  252. package/dist/tenant/web/member-roles-cell.js +1 -1
  253. package/dist/tenant/web/member-status-cell.js +1 -1
  254. package/dist/tenant-inactivity/check-inactive-tenants.d.ts +3 -0
  255. package/dist/tenant-inactivity/check-inactive-tenants.js +184 -0
  256. package/dist/tenant-inactivity/constants.d.ts +10 -0
  257. package/dist/tenant-inactivity/constants.js +10 -0
  258. package/dist/tenant-inactivity/email-templates.d.ts +3 -0
  259. package/dist/tenant-inactivity/email-templates.js +16 -0
  260. package/dist/tenant-inactivity/feature.d.ts +8 -0
  261. package/dist/tenant-inactivity/feature.js +45 -0
  262. package/dist/tenant-inactivity/handlers/inactivity-state.query.d.ts +11 -0
  263. package/dist/tenant-inactivity/handlers/inactivity-state.query.js +45 -0
  264. package/dist/tenant-inactivity/handlers/keep-account.write.d.ts +8 -0
  265. package/dist/tenant-inactivity/handlers/keep-account.write.js +48 -0
  266. package/dist/tenant-inactivity/inactivity-plan.d.ts +51 -0
  267. package/dist/tenant-inactivity/inactivity-plan.js +113 -0
  268. package/dist/tenant-inactivity/index.d.ts +5 -0
  269. package/dist/tenant-inactivity/index.js +3 -0
  270. package/dist/tenant-inactivity/keep-token.d.ts +16 -0
  271. package/dist/tenant-inactivity/keep-token.js +24 -0
  272. package/dist/tenant-inactivity/mail-notifications.d.ts +4 -0
  273. package/dist/tenant-inactivity/mail-notifications.js +42 -0
  274. package/dist/tenant-inactivity/options.d.ts +27 -0
  275. package/dist/tenant-inactivity/options.js +5 -0
  276. package/dist/tenant-inactivity/remote-activity.d.ts +15 -0
  277. package/dist/tenant-inactivity/remote-activity.js +24 -0
  278. package/dist/tenant-inactivity/state-store.d.ts +10 -0
  279. package/dist/tenant-inactivity/state-store.js +50 -0
  280. package/dist/tenant-inactivity/state-table.d.ts +109 -0
  281. package/dist/tenant-inactivity/state-table.js +38 -0
  282. package/dist/tenant-lifecycle/boot-checks.js +8 -3
  283. package/dist/tenant-lifecycle/boot-rules.d.ts +12 -0
  284. package/dist/tenant-lifecycle/boot-rules.js +12 -0
  285. package/dist/tenant-lifecycle/constants.d.ts +1 -0
  286. package/dist/tenant-lifecycle/constants.js +5 -0
  287. package/dist/tenant-lifecycle/events.d.ts +2 -0
  288. package/dist/tenant-lifecycle/events.js +2 -0
  289. package/dist/tenant-lifecycle/feature.js +18 -3
  290. package/dist/tenant-lifecycle/handlers/request-destruction.write.js +11 -67
  291. package/dist/tenant-lifecycle/index.d.ts +2 -1
  292. package/dist/tenant-lifecycle/index.js +2 -1
  293. package/dist/tenant-lifecycle/request-tenant-destruction.d.ts +20 -0
  294. package/dist/tenant-lifecycle/request-tenant-destruction.js +66 -0
  295. package/dist/tenant-lifecycle/retention-config-destroy-hooks.d.ts +5 -0
  296. package/dist/tenant-lifecycle/retention-config-destroy-hooks.js +29 -0
  297. package/dist/tenant-lifecycle/run-tenant-destroy.d.ts +5 -0
  298. package/dist/tenant-lifecycle/run-tenant-destroy.js +85 -12
  299. package/dist/tenant-lifecycle/stages.d.ts +3 -0
  300. package/dist/tenant-lifecycle/stages.js +27 -3
  301. package/dist/tenant-lifecycle/testing.js +1 -1
  302. package/dist/tier-engine/caps-for-tier-from-map.d.ts +5 -0
  303. package/dist/tier-engine/caps-for-tier-from-map.js +12 -0
  304. package/dist/tier-engine/compose-app.d.ts +0 -22
  305. package/dist/tier-engine/compose-app.js +9 -16
  306. package/dist/tier-engine/index.d.ts +1 -0
  307. package/dist/tier-engine/index.js +1 -0
  308. package/dist/user/handlers/detail.query.d.ts +1 -1
  309. package/dist/user-data-rights/feature.js +2 -0
  310. package/dist/user-data-rights/run-forget-cleanup.js +2 -0
  311. package/dist/user-data-rights/web/privacy-center-screen.js +1 -1
  312. package/dist/user-data-rights/zip-path.js +1 -0
  313. package/dist/user-data-rights-defaults/hooks/config-value.userdata-hook.d.ts +1 -1
  314. package/dist/user-data-rights-defaults/hooks/config-value.userdata-hook.js +7 -20
  315. package/dist/user-data-rights-defaults/hooks/delivery-attempt.userdata-hook.js +3 -1
  316. package/dist/user-data-rights-defaults/hooks/forget-own-rows-delete-hook.d.ts +10 -0
  317. package/dist/user-data-rights-defaults/hooks/forget-own-rows-delete-hook.js +26 -0
  318. package/dist/user-data-rights-defaults/hooks/notification-preference.userdata-hook.d.ts +1 -1
  319. package/dist/user-data-rights-defaults/hooks/notification-preference.userdata-hook.js +7 -20
  320. package/dist/user-profile/handlers/change-email.write.js +2 -4
  321. package/dist/user-profile/web/profile-screen.js +2 -3
  322. package/kumiko-es-tables.json +12 -0
  323. package/package.json +46 -12
  324. package/src/admin-shell/changes.json +6 -0
  325. package/src/agent-tools/changes.json +6 -0
  326. package/src/channel-in-app/changes.json +7 -0
  327. package/src/contact/changes.json +27 -0
  328. package/src/data-retention/changes.json +6 -0
  329. package/src/delivery/changes.json +7 -0
  330. package/src/document-ingest-foundation/changes.json +6 -0
  331. package/src/files-tenant-data/changes.json +6 -0
  332. package/src/inbound-mail-foundation/changes.json +13 -0
  333. package/src/secrets/changes.json +6 -0
  334. package/src/sessions/changes.json +6 -0
  335. package/src/tenant-inactivity/changes.json +8 -0
  336. package/src/tenant-lifecycle/changes.json +30 -0
  337. package/src/tier-engine/changes.json +6 -0
@@ -0,0 +1,91 @@
1
+ import { type NotificationLocalizedTemplate, type TemplateVariables } from "@cosmicdrift/kumiko-framework/engine";
2
+ export type ContactMailLocale = "en" | "de";
3
+ export declare function resolveContactMailLocale(locale: string | undefined): ContactMailLocale;
4
+ export declare function truncateText(text: string, maxChars: number): string;
5
+ export declare function contactKindLabel(kind: string, locale: string | undefined): string;
6
+ export declare function formatContactDate(atEpochMs: number, locale: string | undefined): string;
7
+ export declare const CONTACT_NEW_REQUEST_VARIABLES: TemplateVariables;
8
+ export type NewRequestMailArgs = {
9
+ readonly kind: string;
10
+ readonly appName: string;
11
+ readonly link: string | undefined;
12
+ readonly locale: string | undefined;
13
+ };
14
+ export declare function contactNewRequestVariables(args: NewRequestMailArgs): {
15
+ subject: string;
16
+ intro: string;
17
+ requestUrl?: string | undefined;
18
+ inAppTitle: string;
19
+ inAppBody: string;
20
+ telegramTitle: string;
21
+ telegramBody: string;
22
+ };
23
+ export declare function contactNewRequestTemplate(): NotificationLocalizedTemplate;
24
+ export declare const CONTACT_CONFIRMATION_VARIABLES: TemplateVariables;
25
+ export declare function contactConfirmationVariables(args: {
26
+ readonly appName: string;
27
+ readonly message: string;
28
+ readonly locale: string | undefined;
29
+ }): {
30
+ appName: string;
31
+ intro: string;
32
+ quoteIntro: string;
33
+ paragraphs: readonly {
34
+ readonly text: string;
35
+ }[];
36
+ };
37
+ export declare const CONTACT_ACKNOWLEDGEMENT_VARIABLES: TemplateVariables;
38
+ export declare function contactAcknowledgementVariables(args: {
39
+ readonly appName: string;
40
+ readonly locale: string | undefined;
41
+ }): {
42
+ appName: string;
43
+ intro: string;
44
+ };
45
+ export declare function contactAcknowledgementTemplate(): NotificationLocalizedTemplate;
46
+ export declare function contactConfirmationTemplate(): NotificationLocalizedTemplate;
47
+ export declare const CONTACT_REPLY_VARIABLES: TemplateVariables;
48
+ export declare function contactReplyVariables(args: {
49
+ readonly requestSubject: string;
50
+ readonly requestMessage: string;
51
+ readonly requestSubmittedAt: number;
52
+ readonly replyMessage: string;
53
+ readonly authorName: string;
54
+ readonly appName: string;
55
+ readonly locale: string | undefined;
56
+ }): {
57
+ subject: string;
58
+ paragraphs: readonly {
59
+ readonly text: string;
60
+ }[];
61
+ signedBy: string;
62
+ quoteIntro: string;
63
+ quote: string;
64
+ footer: string;
65
+ };
66
+ export declare function contactReplyTemplate(): NotificationLocalizedTemplate;
67
+ export declare const CONTACT_TEST_VARIABLES: TemplateVariables;
68
+ export declare function contactTestVariables(args: {
69
+ readonly appName: string;
70
+ readonly locale: string | undefined;
71
+ }): {
72
+ appName: string;
73
+ telegramTitle: string;
74
+ telegramBody: string;
75
+ };
76
+ export declare function contactTestTemplate(): NotificationLocalizedTemplate;
77
+ export declare function contactReplyInAppData(args: {
78
+ readonly authorName: string;
79
+ readonly locale: string | undefined;
80
+ }): {
81
+ readonly inAppTitle: string;
82
+ readonly inAppBody: string;
83
+ };
84
+ export declare function telegramTemplate(data: Readonly<Record<string, unknown>>): {
85
+ title: string;
86
+ body: string;
87
+ };
88
+ export declare function inAppTemplate(data: Readonly<Record<string, unknown>>): {
89
+ title: string;
90
+ body: string;
91
+ };
@@ -0,0 +1,279 @@
1
+ import { templateVariable, } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { mailHeading, mailParagraph, mailParagraphWithLink, mailRepeatedRows, } from "../shared/index.js";
3
+ import { CONTACT_KIND } from "./web/constants.js";
4
+ const QUOTE_MAX_CHARS = 280;
5
+ function languageOf(locale) {
6
+ return (locale ?? "").split("-")[0]?.toLowerCase() ?? "";
7
+ }
8
+ export function resolveContactMailLocale(locale) {
9
+ return languageOf(locale) === "de" ? "de" : "en";
10
+ }
11
+ export function truncateText(text, maxChars) {
12
+ const chars = [...text];
13
+ return chars.length <= maxChars
14
+ ? text
15
+ : `${chars
16
+ .slice(0, maxChars - 1)
17
+ .join("")
18
+ .trimEnd()}…`;
19
+ }
20
+ const KIND_LABELS = {
21
+ en: {
22
+ [CONTACT_KIND.Question]: "Question",
23
+ [CONTACT_KIND.Contact]: "Contact request",
24
+ [CONTACT_KIND.Bug]: "Problem",
25
+ [CONTACT_KIND.Wish]: "Wish",
26
+ },
27
+ de: {
28
+ [CONTACT_KIND.Question]: "Frage",
29
+ [CONTACT_KIND.Contact]: "Kontaktwunsch",
30
+ [CONTACT_KIND.Bug]: "Problem",
31
+ [CONTACT_KIND.Wish]: "Wunsch",
32
+ },
33
+ };
34
+ export function contactKindLabel(kind, locale) {
35
+ const labels = KIND_LABELS[resolveContactMailLocale(locale)];
36
+ return labels[kind] ?? kind;
37
+ }
38
+ export function formatContactDate(atEpochMs, locale) {
39
+ return new Intl.DateTimeFormat(resolveContactMailLocale(locale), {
40
+ dateStyle: "long",
41
+ timeZone: "UTC",
42
+ }).format(atEpochMs);
43
+ }
44
+ function toParagraphRows(message) {
45
+ return message
46
+ .split(/\r?\n/)
47
+ .map((line) => line.trim())
48
+ .filter((line) => line !== "")
49
+ .map((text) => ({ text }));
50
+ }
51
+ const NEW_REQUEST_STRINGS = {
52
+ en: {
53
+ header: "New request",
54
+ linkIntro: "Open it in the admin:",
55
+ linkLabel: "Show request",
56
+ title: {
57
+ [CONTACT_KIND.Question]: (app) => `New question on ${app}`,
58
+ [CONTACT_KIND.Contact]: (app) => `New contact request on ${app}`,
59
+ [CONTACT_KIND.Bug]: (app) => `New problem report on ${app}`,
60
+ [CONTACT_KIND.Wish]: (app) => `New wish on ${app}`,
61
+ },
62
+ },
63
+ de: {
64
+ header: "Neue Meldung",
65
+ linkIntro: "Im Admin öffnen:",
66
+ linkLabel: "Meldung anzeigen",
67
+ title: {
68
+ [CONTACT_KIND.Question]: (app) => `Neue Frage auf ${app}`,
69
+ [CONTACT_KIND.Contact]: (app) => `Neuer Kontaktwunsch auf ${app}`,
70
+ [CONTACT_KIND.Bug]: (app) => `Neue Problemmeldung auf ${app}`,
71
+ [CONTACT_KIND.Wish]: (app) => `Neuer Wunsch auf ${app}`,
72
+ },
73
+ },
74
+ };
75
+ export const CONTACT_NEW_REQUEST_VARIABLES = {
76
+ subject: templateVariable.text({ required: true }),
77
+ intro: templateVariable.text({ required: true }),
78
+ requestUrl: templateVariable.link(),
79
+ };
80
+ export function contactNewRequestVariables(args) {
81
+ const titles = NEW_REQUEST_STRINGS[resolveContactMailLocale(args.locale)].title;
82
+ const title = (titles[args.kind] ?? titles[CONTACT_KIND.Question])?.(args.appName) ?? args.appName;
83
+ return {
84
+ subject: title,
85
+ intro: title,
86
+ ...(args.link !== undefined && { requestUrl: args.link }),
87
+ inAppTitle: title,
88
+ inAppBody: args.appName,
89
+ telegramTitle: title,
90
+ telegramBody: args.link ?? args.appName,
91
+ };
92
+ }
93
+ export function contactNewRequestTemplate() {
94
+ return Object.fromEntries(Object.entries(NEW_REQUEST_STRINGS).map(([locale, t]) => [
95
+ locale,
96
+ {
97
+ body: [
98
+ mailHeading(t.header),
99
+ mailParagraph("{intro}"),
100
+ mailParagraphWithLink(t.linkIntro, t.linkLabel, "requestUrl", { showIf: "requestUrl" }),
101
+ ].join(""),
102
+ meta: { subject: "{{subject}}", category: "transactional" },
103
+ },
104
+ ]));
105
+ }
106
+ const CONFIRMATION_STRINGS = {
107
+ en: {
108
+ subject: "Your message to {{appName}}",
109
+ header: "Thanks for your message",
110
+ intro: (appName) => `We received your message to the ${appName} team and will get back to you personally. Here is a copy:`,
111
+ quoteIntro: "Your message:",
112
+ },
113
+ de: {
114
+ subject: "Deine Nachricht an {{appName}}",
115
+ header: "Danke für deine Nachricht",
116
+ intro: (appName) => `Deine Nachricht ist beim ${appName}-Team angekommen, wir melden uns persönlich bei dir. Hier ist eine Kopie:`,
117
+ quoteIntro: "Deine Nachricht:",
118
+ },
119
+ };
120
+ const ACKNOWLEDGEMENT_STRINGS = {
121
+ en: {
122
+ subject: "Your message to {{appName}}",
123
+ header: "Thanks for your message",
124
+ intro: (appName) => `We received your message to the ${appName} team and will get back to you personally.`,
125
+ },
126
+ de: {
127
+ subject: "Deine Nachricht an {{appName}}",
128
+ header: "Danke für deine Nachricht",
129
+ intro: (appName) => `Deine Nachricht ist beim ${appName}-Team angekommen, wir melden uns persönlich bei dir.`,
130
+ },
131
+ };
132
+ export const CONTACT_CONFIRMATION_VARIABLES = {
133
+ appName: templateVariable.text({ required: true }),
134
+ intro: templateVariable.text({ required: true }),
135
+ quoteIntro: templateVariable.text({ required: true }),
136
+ paragraphs: templateVariable.list({ text: templateVariable.text({ required: true }) }, { required: true }),
137
+ };
138
+ export function contactConfirmationVariables(args) {
139
+ const t = CONFIRMATION_STRINGS[resolveContactMailLocale(args.locale)];
140
+ return {
141
+ appName: args.appName,
142
+ intro: t.intro(args.appName),
143
+ quoteIntro: t.quoteIntro,
144
+ paragraphs: toParagraphRows(args.message),
145
+ };
146
+ }
147
+ // Website senders are unverified addresses: the mail must not echo anything they typed, or the
148
+ // form becomes a mail relay. Only the signed-in admin report gets the copy above.
149
+ export const CONTACT_ACKNOWLEDGEMENT_VARIABLES = {
150
+ appName: templateVariable.text({ required: true }),
151
+ intro: templateVariable.text({ required: true }),
152
+ };
153
+ export function contactAcknowledgementVariables(args) {
154
+ const t = ACKNOWLEDGEMENT_STRINGS[resolveContactMailLocale(args.locale)];
155
+ return { appName: args.appName, intro: t.intro(args.appName) };
156
+ }
157
+ export function contactAcknowledgementTemplate() {
158
+ return Object.fromEntries(Object.entries(ACKNOWLEDGEMENT_STRINGS).map(([locale, t]) => [
159
+ locale,
160
+ {
161
+ body: [mailHeading(t.header), mailParagraph("{intro}")].join(""),
162
+ meta: { subject: t.subject, category: "transactional" },
163
+ },
164
+ ]));
165
+ }
166
+ export function contactConfirmationTemplate() {
167
+ return Object.fromEntries(Object.entries(CONFIRMATION_STRINGS).map(([locale, t]) => [
168
+ locale,
169
+ {
170
+ body: [
171
+ mailHeading(t.header),
172
+ mailParagraph("{intro}"),
173
+ mailParagraph("{quoteIntro}"),
174
+ mailRepeatedRows("paragraphs", "text"),
175
+ ].join(""),
176
+ meta: { subject: t.subject, category: "transactional" },
177
+ },
178
+ ]));
179
+ }
180
+ const REPLY_STRINGS = {
181
+ en: {
182
+ footer: "You can reply directly to this email.",
183
+ quoteIntro: (date) => `Your request from ${date}:`,
184
+ },
185
+ de: {
186
+ footer: "Du kannst direkt auf diese Mail antworten.",
187
+ quoteIntro: (date) => `Deine Meldung vom ${date}:`,
188
+ },
189
+ };
190
+ export const CONTACT_REPLY_VARIABLES = {
191
+ subject: templateVariable.text({ required: true }),
192
+ paragraphs: templateVariable.list({ text: templateVariable.text({ required: true }) }, { required: true }),
193
+ signedBy: templateVariable.text({ required: true }),
194
+ quoteIntro: templateVariable.text({ required: true }),
195
+ quote: templateVariable.text({ required: true }),
196
+ footer: templateVariable.text({ required: true }),
197
+ };
198
+ export function contactReplyVariables(args) {
199
+ const t = REPLY_STRINGS[resolveContactMailLocale(args.locale)];
200
+ return {
201
+ subject: `Re: ${args.requestSubject}`,
202
+ paragraphs: toParagraphRows(args.replyMessage),
203
+ signedBy: `${args.authorName}, ${args.appName}`,
204
+ quoteIntro: t.quoteIntro(formatContactDate(args.requestSubmittedAt, args.locale)),
205
+ quote: truncateText(args.requestMessage.replace(/\s+/g, " "), QUOTE_MAX_CHARS),
206
+ footer: t.footer,
207
+ };
208
+ }
209
+ export function contactReplyTemplate() {
210
+ return Object.fromEntries(Object.keys(REPLY_STRINGS).map((locale) => [
211
+ locale,
212
+ {
213
+ body: [
214
+ mailRepeatedRows("paragraphs", "text"),
215
+ mailParagraph("{signedBy}"),
216
+ mailParagraph("{quoteIntro}"),
217
+ mailParagraph("{quote}"),
218
+ mailParagraph("{footer}"),
219
+ ].join(""),
220
+ meta: { subject: "{{subject}}", category: "transactional" },
221
+ },
222
+ ]));
223
+ }
224
+ const TEST_STRINGS = {
225
+ en: {
226
+ subject: "Test message from {{appName}}",
227
+ header: "Test message",
228
+ intro: "This is a test message of the contact forwarding.",
229
+ },
230
+ de: {
231
+ subject: "Testnachricht von {{appName}}",
232
+ header: "Testnachricht",
233
+ intro: "Das ist eine Testnachricht der Weiterleitung von Meldungen.",
234
+ },
235
+ };
236
+ export const CONTACT_TEST_VARIABLES = {
237
+ appName: templateVariable.text({ required: true }),
238
+ };
239
+ export function contactTestVariables(args) {
240
+ const t = TEST_STRINGS[resolveContactMailLocale(args.locale)];
241
+ return {
242
+ appName: args.appName,
243
+ telegramTitle: t.subject.replace("{{appName}}", args.appName),
244
+ telegramBody: t.intro,
245
+ };
246
+ }
247
+ export function contactTestTemplate() {
248
+ return Object.fromEntries(Object.entries(TEST_STRINGS).map(([locale, t]) => [
249
+ locale,
250
+ {
251
+ body: [mailHeading(t.header), mailParagraph(t.intro)].join(""),
252
+ meta: { subject: t.subject, category: "transactional" },
253
+ },
254
+ ]));
255
+ }
256
+ const REPLY_IN_APP_STRINGS = {
257
+ en: (authorName) => ({
258
+ title: "Answer to your request",
259
+ body: `${authorName} replied. The answer is in your inbox.`,
260
+ }),
261
+ de: (authorName) => ({
262
+ title: "Antwort auf deine Meldung",
263
+ body: `${authorName} hat geantwortet. Die Antwort liegt in deinem Postfach.`,
264
+ }),
265
+ };
266
+ export function contactReplyInAppData(args) {
267
+ const copy = REPLY_IN_APP_STRINGS[resolveContactMailLocale(args.locale)](args.authorName);
268
+ return { inAppTitle: copy.title, inAppBody: copy.body };
269
+ }
270
+ function stringField(data, key) {
271
+ const value = data[key];
272
+ return typeof value === "string" ? value : "";
273
+ }
274
+ export function telegramTemplate(data) {
275
+ return { title: stringField(data, "telegramTitle"), body: stringField(data, "telegramBody") };
276
+ }
277
+ export function inAppTemplate(data) {
278
+ return { title: stringField(data, "inAppTitle"), body: stringField(data, "inAppBody") };
279
+ }
@@ -0,0 +1,51 @@
1
+ import type { PayloadRateLimitOption, RateLimitDeclaration, RateLimitOption } from "@cosmicdrift/kumiko-types/handlers";
2
+ import { type ContactPhoneMode } from "./web/constants.ts";
3
+ export type ContactOptions = {
4
+ /** Name shown in the notification mails ("Testnachricht von <appName>"); the static screen texts do not name it. */
5
+ readonly appName: string;
6
+ /** Default { phone: "off" }. Controls both the public form (challenge query reports it) and the admin report form. */
7
+ readonly fields?: {
8
+ readonly phone?: ContactPhoneMode;
9
+ };
10
+ /** Shown as "Version" in the request origin; omitted when unset. */
11
+ readonly appVersion?: string;
12
+ /** Default false. true requires channel-telegram and adds the `telegramChat` config key, the `send-test` handler and the forward to that chat. */
13
+ readonly telegram?: boolean;
14
+ /** Screen the admin report form's Cancel button navigates to (short id or `<feature>:screen:<id>`). Default: no Cancel button. */
15
+ readonly reportCancelTarget?: string;
16
+ /** Screens the sender and tenant links in the request detail header open (short id or `<feature>:screen:<id>`). Default `user-edit` and `tenant-edit`; `false` shows plain text. */
17
+ readonly detailLinks?: {
18
+ readonly user?: string | false;
19
+ readonly tenant?: string | false;
20
+ };
21
+ /** Language of the notification mails and Telegram texts SystemAdmins receive. Default "en". */
22
+ readonly adminLocale?: string;
23
+ /** Deep link to the request in the admin, put into the notification mail and the Telegram text. Omitted: no link. */
24
+ readonly requestLink?: (requestId: string) => string;
25
+ /** Per-IP limit of the public submit. Default 5 per IP per 10 minutes. */
26
+ readonly rateLimit?: RateLimitDeclaration;
27
+ /** Default: 3 per email address per day. `[]` disables. */
28
+ readonly emailRateLimits?: readonly PayloadRateLimitOption[];
29
+ readonly spamProtection?: {
30
+ /** Default 3. Submits faster than this after the challenge was issued are silently dropped. */
31
+ readonly minSubmitSeconds?: number;
32
+ /** Leading zero bits of SHA-256(challenge + ":" + nonce). Default 19, min 8, max 26. */
33
+ readonly proofOfWorkBits?: number;
34
+ /** Default 30. */
35
+ readonly challengeTtlMinutes?: number;
36
+ };
37
+ /** Retention of requests and replies, data-retention keepFor syntax. Default "365d" counted from submittedAt. */
38
+ readonly retentionKeepFor?: string;
39
+ };
40
+ export declare const DEFAULT_SUBMIT_RATE_LIMIT: RateLimitOption;
41
+ export declare const REPORT_RATE_LIMIT: RateLimitOption;
42
+ export declare const CHALLENGE_RATE_LIMIT: RateLimitOption;
43
+ export declare const DEFAULT_SUBMIT_EMAIL_RATE_LIMITS: readonly PayloadRateLimitOption[];
44
+ export declare const DEFAULT_RETENTION_KEEP_FOR = "365d";
45
+ export type ContactSettings = {
46
+ readonly phone: ContactPhoneMode;
47
+ readonly proofOfWorkBits: number;
48
+ readonly minSubmitMs: number;
49
+ readonly challengeTtlSeconds: number;
50
+ };
51
+ export declare function resolveContactSettings(opts: ContactOptions): ContactSettings;
@@ -0,0 +1,32 @@
1
+ import { CONTACT_DEFAULT_CHALLENGE_TTL_MINUTES, CONTACT_DEFAULT_MIN_SUBMIT_SECONDS, CONTACT_POW_BITS, } from "./web/constants.js";
2
+ export const DEFAULT_SUBMIT_RATE_LIMIT = {
3
+ per: "ip+handler",
4
+ limit: 5,
5
+ windowSeconds: 10 * 60,
6
+ };
7
+ export const REPORT_RATE_LIMIT = {
8
+ per: "user+handler",
9
+ limit: 10,
10
+ windowSeconds: 60 * 60,
11
+ };
12
+ export const CHALLENGE_RATE_LIMIT = {
13
+ per: "ip+handler",
14
+ limit: 30,
15
+ windowSeconds: 10 * 60,
16
+ };
17
+ export const DEFAULT_SUBMIT_EMAIL_RATE_LIMITS = [
18
+ { per: { payloadField: "email" }, limit: 3, windowSeconds: 24 * 60 * 60, normalize: "email" },
19
+ ];
20
+ export const DEFAULT_RETENTION_KEEP_FOR = "365d";
21
+ export function resolveContactSettings(opts) {
22
+ const bits = opts.spamProtection?.proofOfWorkBits ?? CONTACT_POW_BITS.default;
23
+ if (!Number.isInteger(bits) || bits < CONTACT_POW_BITS.min || bits > CONTACT_POW_BITS.max) {
24
+ throw new Error(`contact: spamProtection.proofOfWorkBits must be an integer between ${CONTACT_POW_BITS.min} and ${CONTACT_POW_BITS.max}, got ${bits}`);
25
+ }
26
+ return {
27
+ phone: opts.fields?.phone ?? "off",
28
+ proofOfWorkBits: bits,
29
+ minSubmitMs: (opts.spamProtection?.minSubmitSeconds ?? CONTACT_DEFAULT_MIN_SUBMIT_SECONDS) * 1000,
30
+ challengeTtlSeconds: (opts.spamProtection?.challengeTtlMinutes ?? CONTACT_DEFAULT_CHALLENGE_TTL_MINUTES) * 60,
31
+ };
32
+ }
@@ -0,0 +1,2 @@
1
+ import type { DashboardStatPanel } from "@cosmicdrift/kumiko-framework/ui-types";
2
+ export declare function contactOpenRequestsPanels(): readonly DashboardStatPanel[];
@@ -0,0 +1,21 @@
1
+ import { CONTACT_FEATURE, CONTACT_STATUS, ContactQueries, ContactScreens, } from "./web/constants.js";
2
+ // Stat tile for a dashboard: how many contact requests still wait for a first answer.
3
+ export function contactOpenRequestsPanels() {
4
+ return [
5
+ {
6
+ kind: "stat",
7
+ id: `${CONTACT_FEATURE}-open-requests`,
8
+ label: "contact:overview.open",
9
+ query: ContactQueries.requestList,
10
+ params: {
11
+ filters: [{ field: "status", op: "eq", value: CONTACT_STATUS.Open }],
12
+ limit: 1,
13
+ totalCount: true,
14
+ },
15
+ ignoreScreenFilter: true,
16
+ valueField: "total",
17
+ tone: "warn",
18
+ navigate: { screen: ContactScreens.requestList },
19
+ },
20
+ ];
21
+ }
@@ -0,0 +1,56 @@
1
+ import * as z from "zod";
2
+ export declare const ContactSubmitSchema: z.ZodObject<{
3
+ kind: z.ZodEnum<{
4
+ bug: "bug";
5
+ contact: "contact";
6
+ question: "question";
7
+ }>;
8
+ name: z.ZodString;
9
+ email: z.ZodEmail;
10
+ phone: z.ZodOptional<z.ZodString>;
11
+ message: z.ZodString;
12
+ locale: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
13
+ website: z.ZodOptional<z.ZodString>;
14
+ challenge: z.ZodString;
15
+ nonce: z.ZodString;
16
+ page: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
17
+ }, z.core.$strict>;
18
+ export type ContactSubmitInput = z.infer<typeof ContactSubmitSchema>;
19
+ export declare const ContactReportSchema: z.ZodObject<{
20
+ kind: z.ZodEnum<{
21
+ bug: "bug";
22
+ question: "question";
23
+ wish: "wish";
24
+ }>;
25
+ subject: z.ZodString;
26
+ message: z.ZodString;
27
+ phone: z.ZodOptional<z.ZodString>;
28
+ fileIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
29
+ }, z.core.$strict>;
30
+ export type ContactReportInput = z.infer<typeof ContactReportSchema>;
31
+ export declare const ContactIdSchema: z.ZodObject<{
32
+ id: z.ZodUUID;
33
+ }, z.core.$strict>;
34
+ export declare const ContactReplySchema: z.ZodObject<{
35
+ requestId: z.ZodUUID;
36
+ message: z.ZodString;
37
+ fileIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
38
+ markDone: z.ZodDefault<z.ZodBoolean>;
39
+ }, z.core.$strict>;
40
+ export declare const ContactMarkDoneSchema: z.ZodObject<{
41
+ id: z.ZodUUID;
42
+ }, z.core.$strict>;
43
+ export declare const ContactForwardRequestSchema: z.ZodObject<{
44
+ requestId: z.ZodUUID;
45
+ }, z.core.$strict>;
46
+ export declare const ContactSendReplyMailSchema: z.ZodObject<{
47
+ replyId: z.ZodUUID;
48
+ }, z.core.$strict>;
49
+ export declare const ContactNotifyReporterInAppSchema: z.ZodObject<{
50
+ replyId: z.ZodUUID;
51
+ requestId: z.ZodUUID;
52
+ userId: z.ZodUUID;
53
+ authorName: z.ZodString;
54
+ locale: z.ZodOptional<z.ZodString>;
55
+ }, z.core.$strict>;
56
+ export declare const ContactEmptySchema: z.ZodObject<{}, z.core.$strict>;
@@ -0,0 +1,82 @@
1
+ import { canonicalizeLocaleTag, isValidLocaleTag } from "@cosmicdrift/kumiko-framework/i18n";
2
+ import * as z from "zod";
3
+ import { CONTACT_ADMIN_KINDS, CONTACT_FIELD_LIMITS, CONTACT_MAX_FILES, CONTACT_WEBSITE_KINDS, } from "./web/constants.js";
4
+ // Submitted text lands in mail subjects; CR/LF there would allow header injection.
5
+ const NO_CONTROL_CHARS = /^\P{Cc}*$/u;
6
+ const NO_CONTROL_CHARS_EXCEPT_WHITESPACE = /^(?:[^\p{Cc}]|[\n\r\t])*$/u;
7
+ const noControlChars = (value) => NO_CONTROL_CHARS.test(value);
8
+ const CONTROL_CHARS_MESSAGE = "control characters not allowed";
9
+ const singleLine = (max) => z.string().trim().min(1).max(max).refine(noControlChars, CONTROL_CHARS_MESSAGE);
10
+ const multiLine = (max) => z
11
+ .string()
12
+ .trim()
13
+ .min(1)
14
+ .max(max)
15
+ .refine((value) => NO_CONTROL_CHARS_EXCEPT_WHITESPACE.test(value), CONTROL_CHARS_MESSAGE);
16
+ // An empty phone field of a form counts as absent.
17
+ const phone = z
18
+ .string()
19
+ .trim()
20
+ .max(CONTACT_FIELD_LIMITS.phone)
21
+ .refine(noControlChars, CONTROL_CHARS_MESSAGE)
22
+ .optional();
23
+ const pagePath = z
24
+ .string()
25
+ .trim()
26
+ .max(CONTACT_FIELD_LIMITS.page)
27
+ .refine(noControlChars, CONTROL_CHARS_MESSAGE)
28
+ // Query strings and fragments carry tokens and ids (reset links, session hints) that must not
29
+ // end up in an inbox that is kept for a year.
30
+ .transform((value) => value.split(/[?#]/, 1)[0] ?? "")
31
+ .optional();
32
+ const locale = z
33
+ .string()
34
+ .max(CONTACT_FIELD_LIMITS.locale)
35
+ .refine(isValidLocaleTag, "invalid locale tag")
36
+ .transform(canonicalizeLocaleTag);
37
+ export const ContactSubmitSchema = z
38
+ .object({
39
+ kind: z.enum(CONTACT_WEBSITE_KINDS),
40
+ name: singleLine(CONTACT_FIELD_LIMITS.name),
41
+ email: z.email().max(CONTACT_FIELD_LIMITS.email),
42
+ phone,
43
+ message: multiLine(CONTACT_FIELD_LIMITS.message),
44
+ locale,
45
+ // Honeypot: bots fill it, humans leave it empty.
46
+ website: z.string().max(CONTACT_FIELD_LIMITS.honeypot).optional(),
47
+ challenge: z.string().max(CONTACT_FIELD_LIMITS.challenge),
48
+ nonce: z.string().max(CONTACT_FIELD_LIMITS.nonce),
49
+ page: pagePath,
50
+ })
51
+ .strict();
52
+ export const ContactReportSchema = z
53
+ .object({
54
+ kind: z.enum(CONTACT_ADMIN_KINDS),
55
+ subject: singleLine(CONTACT_FIELD_LIMITS.subject),
56
+ message: multiLine(CONTACT_FIELD_LIMITS.message),
57
+ phone,
58
+ fileIds: z.array(z.uuid()).max(CONTACT_MAX_FILES).optional(),
59
+ })
60
+ .strict();
61
+ export const ContactIdSchema = z.object({ id: z.uuid() }).strict();
62
+ export const ContactReplySchema = z
63
+ .object({
64
+ requestId: z.uuid(),
65
+ message: multiLine(CONTACT_FIELD_LIMITS.message),
66
+ fileIds: z.array(z.uuid()).max(CONTACT_MAX_FILES).optional(),
67
+ markDone: z.boolean().default(false),
68
+ })
69
+ .strict();
70
+ export const ContactMarkDoneSchema = ContactIdSchema;
71
+ export const ContactForwardRequestSchema = z.object({ requestId: z.uuid() }).strict();
72
+ export const ContactSendReplyMailSchema = z.object({ replyId: z.uuid() }).strict();
73
+ export const ContactNotifyReporterInAppSchema = z
74
+ .object({
75
+ replyId: z.uuid(),
76
+ requestId: z.uuid(),
77
+ userId: z.uuid(),
78
+ authorName: z.string().max(CONTACT_FIELD_LIMITS.name),
79
+ locale: z.string().max(CONTACT_FIELD_LIMITS.locale).optional(),
80
+ })
81
+ .strict();
82
+ export const ContactEmptySchema = z.object({}).strict();
@@ -0,0 +1,6 @@
1
+ export declare function hasLeadingZeroBits(hash: Uint8Array, bits: number): boolean;
2
+ export declare function verifyProofOfWork(args: {
3
+ readonly challenge: string;
4
+ readonly nonce: string;
5
+ readonly bits: number;
6
+ }): boolean;
@@ -0,0 +1,19 @@
1
+ import { createHash } from "node:crypto";
2
+ export function hasLeadingZeroBits(hash, bits) {
3
+ const fullBytes = Math.floor(bits / 8);
4
+ for (let index = 0; index < fullBytes; index++) {
5
+ if (hash[index] !== 0)
6
+ return false;
7
+ }
8
+ const remainingBits = bits % 8;
9
+ if (remainingBits === 0)
10
+ return true;
11
+ const next = hash[fullBytes];
12
+ if (next === undefined)
13
+ return false;
14
+ return next >> (8 - remainingBits) === 0;
15
+ }
16
+ export function verifyProofOfWork(args) {
17
+ const hash = createHash("sha256").update(`${args.challenge}:${args.nonce}`).digest();
18
+ return hasLeadingZeroBits(hash, args.bits);
19
+ }
@@ -0,0 +1,5 @@
1
+ import type { ScreenDefinition } from "@cosmicdrift/kumiko-framework/ui-types";
2
+ import type { ContactOptions, ContactSettings } from "./options.ts";
3
+ export declare const REPORT_FIELD_LABEL: string;
4
+ export declare const REPLY_FIELD_LABEL: string;
5
+ export declare function createContactScreens(opts: ContactOptions, settings: ContactSettings): readonly ScreenDefinition[];