@redacto.io/consent-sdk-react 10.0.0-beta.9 → 10.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 (264) hide show
  1. package/NOTICE.md +17 -0
  2. package/README.md +141 -3
  3. package/dist/chunk-FEGTW73Q.mjs +182 -0
  4. package/dist/fonts.d.mts +35 -0
  5. package/dist/fonts.d.ts +35 -0
  6. package/dist/fonts.js +183 -0
  7. package/dist/fonts.mjs +10 -0
  8. package/dist/index.d.mts +12 -1
  9. package/dist/index.d.ts +12 -1
  10. package/dist/index.js +724 -365
  11. package/dist/index.mjs +346 -201
  12. package/dist/montserrat.generated-NBTECYRW.mjs +22 -0
  13. package/dist/privacy-center.d.mts +0 -1
  14. package/dist/privacy-center.d.ts +0 -1
  15. package/dist/privacy-center.js +2 -66
  16. package/dist/privacy-center.mjs +2 -66
  17. package/dist/types-6Aj7faxL.d.mts +57 -0
  18. package/dist/types-6Aj7faxL.d.ts +57 -0
  19. package/package.json +10 -1
  20. package/.turbo/turbo-build.log +0 -22
  21. package/.turbo/turbo-test.log +0 -203
  22. package/.turbo/turbo-verify-pack.log +0 -6
  23. package/CHANGELOG.md +0 -353
  24. package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.test.tsx +0 -934
  25. package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.tsx +0 -2160
  26. package/src/RedactoNoticeAssisted/api/index.ts +0 -275
  27. package/src/RedactoNoticeAssisted/api/types.ts +0 -182
  28. package/src/RedactoNoticeAssisted/assets/redacto-logo.png +0 -0
  29. package/src/RedactoNoticeAssisted/constants.ts +0 -51
  30. package/src/RedactoNoticeAssisted/i18n.ts +0 -1408
  31. package/src/RedactoNoticeAssisted/index.ts +0 -1
  32. package/src/RedactoNoticeAssisted/injectStyles.ts +0 -251
  33. package/src/RedactoNoticeAssisted/styles.ts +0 -730
  34. package/src/RedactoNoticeAssisted/types.ts +0 -26
  35. package/src/RedactoNoticeAssisted/useMediaQuery.ts +0 -36
  36. package/src/RedactoNoticeConsent/RedactoNoticeConsent.test.tsx +0 -1152
  37. package/src/RedactoNoticeConsent/RedactoNoticeConsent.tsx +0 -4308
  38. package/src/RedactoNoticeConsent/api/index.ts +0 -542
  39. package/src/RedactoNoticeConsent/api/sandbox.ts +0 -150
  40. package/src/RedactoNoticeConsent/api/types.ts +0 -515
  41. package/src/RedactoNoticeConsent/assets/redacto-logo.png +0 -0
  42. package/src/RedactoNoticeConsent/components/DigiLockerCallback.tsx +0 -602
  43. package/src/RedactoNoticeConsent/components/index.ts +0 -7
  44. package/src/RedactoNoticeConsent/constants.ts +0 -20
  45. package/src/RedactoNoticeConsent/index.ts +0 -1
  46. package/src/RedactoNoticeConsent/injectStyles.ts +0 -151
  47. package/src/RedactoNoticeConsent/language-codes.ts +0 -95
  48. package/src/RedactoNoticeConsent/services/storage.ts +0 -122
  49. package/src/RedactoNoticeConsent/styles.ts +0 -409
  50. package/src/RedactoNoticeConsent/types.ts +0 -80
  51. package/src/RedactoNoticeConsent/useMediaQuery.ts +0 -36
  52. package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.test.tsx +0 -369
  53. package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.tsx +0 -687
  54. package/src/RedactoNoticeConsentInline/api/index.ts +0 -106
  55. package/src/RedactoNoticeConsentInline/api/types.ts +0 -183
  56. package/src/RedactoNoticeConsentInline/assets/redacto-logo.png +0 -0
  57. package/src/RedactoNoticeConsentInline/index.ts +0 -1
  58. package/src/RedactoNoticeConsentInline/injectStyles.ts +0 -40
  59. package/src/RedactoNoticeConsentInline/styles.ts +0 -397
  60. package/src/RedactoNoticeConsentInline/types.ts +0 -51
  61. package/src/RedactoNoticeConsentInline/useMediaQuery.ts +0 -36
  62. package/src/RedactoPrivacyCenter/NotificationsPage.tsx +0 -182
  63. package/src/RedactoPrivacyCenter/PrivacyCenterActivityPage.tsx +0 -19
  64. package/src/RedactoPrivacyCenter/PrivacyCenterCaseDetailsPage.tsx +0 -156
  65. package/src/RedactoPrivacyCenter/PrivacyCenterConsentManagerPage.tsx +0 -17
  66. package/src/RedactoPrivacyCenter/PrivacyCenterFormPage.tsx +0 -79
  67. package/src/RedactoPrivacyCenter/PrivacyCenterHomePage.tsx +0 -36
  68. package/src/RedactoPrivacyCenter/PrivacyCenterLayout.tsx +0 -177
  69. package/src/RedactoPrivacyCenter/PrivacyCenterMyReceiptPage.tsx +0 -26
  70. package/src/RedactoPrivacyCenter/RedactoPrivacyCenter.tsx +0 -93
  71. package/src/RedactoPrivacyCenter/api/actions.ts +0 -695
  72. package/src/RedactoPrivacyCenter/api/client.ts +0 -1003
  73. package/src/RedactoPrivacyCenter/api/config.ts +0 -33
  74. package/src/RedactoPrivacyCenter/api/fetcher.ts +0 -275
  75. package/src/RedactoPrivacyCenter/api/orgBranding.ts +0 -16
  76. package/src/RedactoPrivacyCenter/api/upload.ts +0 -93
  77. package/src/RedactoPrivacyCenter/assets/character.svg +0 -31
  78. package/src/RedactoPrivacyCenter/assets/fileAttach.svg +0 -9
  79. package/src/RedactoPrivacyCenter/assets/greenTick.svg +0 -4
  80. package/src/RedactoPrivacyCenter/assets/mail.svg +0 -3
  81. package/src/RedactoPrivacyCenter/assets/poweredByRedacto.svg +0 -9
  82. package/src/RedactoPrivacyCenter/assets/sentImg.svg +0 -9
  83. package/src/RedactoPrivacyCenter/assets/uploadFileIcon.svg +0 -9
  84. package/src/RedactoPrivacyCenter/components/ActivitiesList.tsx +0 -252
  85. package/src/RedactoPrivacyCenter/components/ActivityTimeline.tsx +0 -239
  86. package/src/RedactoPrivacyCenter/components/AppShell/AppShell.tsx +0 -268
  87. package/src/RedactoPrivacyCenter/components/AppShell/MobileNavDrawer.tsx +0 -218
  88. package/src/RedactoPrivacyCenter/components/AppShell/NavItem.tsx +0 -205
  89. package/src/RedactoPrivacyCenter/components/AppShell/PageHeader.tsx +0 -107
  90. package/src/RedactoPrivacyCenter/components/AppShell/SidebarNav.tsx +0 -100
  91. package/src/RedactoPrivacyCenter/components/AppShell/TopAppBar.tsx +0 -339
  92. package/src/RedactoPrivacyCenter/components/AppShell/UserMenu.tsx +0 -245
  93. package/src/RedactoPrivacyCenter/components/AppShell/hooks/useIsTruncated.ts +0 -28
  94. package/src/RedactoPrivacyCenter/components/AppShell/hooks/useKeyboardShortcut.ts +0 -40
  95. package/src/RedactoPrivacyCenter/components/AppShell/hooks/useSidebarState.ts +0 -62
  96. package/src/RedactoPrivacyCenter/components/AppShell/usePrivacyCenterExitAction.ts +0 -36
  97. package/src/RedactoPrivacyCenter/components/CaseDetails/AttachmentCard.tsx +0 -38
  98. package/src/RedactoPrivacyCenter/components/CaseDetails/ChatBubble.tsx +0 -31
  99. package/src/RedactoPrivacyCenter/components/CaseDetails/DocumentRequestCard.tsx +0 -79
  100. package/src/RedactoPrivacyCenter/components/CaseDetails/FinalizedTooltipWrapper.tsx +0 -25
  101. package/src/RedactoPrivacyCenter/components/CaseDetails/MessageComposer.tsx +0 -96
  102. package/src/RedactoPrivacyCenter/components/CaseDetails/MessageItem.tsx +0 -97
  103. package/src/RedactoPrivacyCenter/components/CaseDetails/MessagesTab.tsx +0 -156
  104. package/src/RedactoPrivacyCenter/components/CaseDetails/RequestDetailsTab.tsx +0 -171
  105. package/src/RedactoPrivacyCenter/components/CaseDetails/StatusEvent.tsx +0 -23
  106. package/src/RedactoPrivacyCenter/components/CaseDetails/useFileUpload.ts +0 -116
  107. package/src/RedactoPrivacyCenter/components/CaseDetails/useMessagePolling.ts +0 -43
  108. package/src/RedactoPrivacyCenter/components/CaseDetails/utils.ts +0 -71
  109. package/src/RedactoPrivacyCenter/components/CaseDetailsModal.tsx +0 -469
  110. package/src/RedactoPrivacyCenter/components/CaseHistory.tsx +0 -426
  111. package/src/RedactoPrivacyCenter/components/ConsentManager.tsx +0 -1206
  112. package/src/RedactoPrivacyCenter/components/ConsentManagerCells.tsx +0 -218
  113. package/src/RedactoPrivacyCenter/components/ConsentManagerColumns.tsx +0 -138
  114. package/src/RedactoPrivacyCenter/components/ConsentManagerConstants.ts +0 -7
  115. package/src/RedactoPrivacyCenter/components/ConsentManagerExpandedRow.tsx +0 -179
  116. package/src/RedactoPrivacyCenter/components/ConsentManagerGroupedColumns.tsx +0 -318
  117. package/src/RedactoPrivacyCenter/components/ConsentManagerProductCards.tsx +0 -333
  118. package/src/RedactoPrivacyCenter/components/ConsentManagerPurposeCards.tsx +0 -102
  119. package/src/RedactoPrivacyCenter/components/ConsentManagerTableSkeleton.tsx +0 -159
  120. package/src/RedactoPrivacyCenter/components/DataRequest/CorrectionDataSection.tsx +0 -189
  121. package/src/RedactoPrivacyCenter/components/DataRequest/GrievanceDataSection.tsx +0 -118
  122. package/src/RedactoPrivacyCenter/components/DataRequest/NominationDataSection.tsx +0 -66
  123. package/src/RedactoPrivacyCenter/components/DataRequest/ProductSelectionSection.tsx +0 -222
  124. package/src/RedactoPrivacyCenter/components/DataRequest/PurposeSelectionSection.tsx +0 -331
  125. package/src/RedactoPrivacyCenter/components/Form.tsx +0 -1821
  126. package/src/RedactoPrivacyCenter/components/GrievanceTable.tsx +0 -174
  127. package/src/RedactoPrivacyCenter/components/GrievanceTablePagination.tsx +0 -337
  128. package/src/RedactoPrivacyCenter/components/ModifyConsentModal.tsx +0 -334
  129. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationBell.tsx +0 -173
  130. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationCTAButton.tsx +0 -18
  131. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationDropdown.tsx +0 -54
  132. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationDropdownItem.tsx +0 -57
  133. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationIcon.tsx +0 -19
  134. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationListPanel.tsx +0 -92
  135. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationRefreshButton.tsx +0 -20
  136. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationRow.tsx +0 -58
  137. package/src/RedactoPrivacyCenter/components/NotificationHub/StatCard.tsx +0 -10
  138. package/src/RedactoPrivacyCenter/components/NotificationHub/useNotificationActions.ts +0 -112
  139. package/src/RedactoPrivacyCenter/components/NotificationHub/utils.ts +0 -27
  140. package/src/RedactoPrivacyCenter/components/Pagination.tsx +0 -140
  141. package/src/RedactoPrivacyCenter/components/PrivacyCenterEmptyState.tsx +0 -76
  142. package/src/RedactoPrivacyCenter/components/PrivacyCenterSessionExpired.tsx +0 -97
  143. package/src/RedactoPrivacyCenter/components/ReceiptsList.tsx +0 -454
  144. package/src/RedactoPrivacyCenter/components/RequestSubmit.tsx +0 -270
  145. package/src/RedactoPrivacyCenter/components/SelectUser.tsx +0 -95
  146. package/src/RedactoPrivacyCenter/components/SelectUserGate.tsx +0 -195
  147. package/src/RedactoPrivacyCenter/components/SideMenuBarPC/constants.tsx +0 -25
  148. package/src/RedactoPrivacyCenter/components/SideMenuBarPC/types.ts +0 -21
  149. package/src/RedactoPrivacyCenter/components/caseHistoryColumns.tsx +0 -159
  150. package/src/RedactoPrivacyCenter/components/constant.ts +0 -52
  151. package/src/RedactoPrivacyCenter/components/groupHelpers.ts +0 -155
  152. package/src/RedactoPrivacyCenter/components/receiptColumns.tsx +0 -203
  153. package/src/RedactoPrivacyCenter/components/types.ts +0 -123
  154. package/src/RedactoPrivacyCenter/components/utils.tsx +0 -10
  155. package/src/RedactoPrivacyCenter/config/routes.ts +0 -9
  156. package/src/RedactoPrivacyCenter/config/table.ts +0 -25
  157. package/src/RedactoPrivacyCenter/context/AuthContext.tsx +0 -252
  158. package/src/RedactoPrivacyCenter/context/BaseUrlContext.tsx +0 -47
  159. package/src/RedactoPrivacyCenter/context/BrandingContext.tsx +0 -52
  160. package/src/RedactoPrivacyCenter/context/DataAvailabilityContext.session-expired.test.tsx +0 -92
  161. package/src/RedactoPrivacyCenter/context/DataAvailabilityContext.tsx +0 -181
  162. package/src/RedactoPrivacyCenter/context/LocaleContext.tsx +0 -11
  163. package/src/RedactoPrivacyCenter/context/NavigationContext.tsx +0 -96
  164. package/src/RedactoPrivacyCenter/context/OrganizationContext.tsx +0 -30
  165. package/src/RedactoPrivacyCenter/context/PageChromeContext.tsx +0 -80
  166. package/src/RedactoPrivacyCenter/context/ProfileSwitchContext.tsx +0 -15
  167. package/src/RedactoPrivacyCenter/context/types.ts +0 -57
  168. package/src/RedactoPrivacyCenter/lib/api.ts +0 -759
  169. package/src/RedactoPrivacyCenter/lib/consent-manager/utils.tsx +0 -67
  170. package/src/RedactoPrivacyCenter/lib/constants.ts +0 -283
  171. package/src/RedactoPrivacyCenter/lib/i18n.ts +0 -81
  172. package/src/RedactoPrivacyCenter/lib/locales.ts +0 -102
  173. package/src/RedactoPrivacyCenter/lib/queries.ts +0 -141
  174. package/src/RedactoPrivacyCenter/lib/sandbox.ts +0 -104
  175. package/src/RedactoPrivacyCenter/lib/types.ts +0 -896
  176. package/src/RedactoPrivacyCenter/lib/useCurrentLanguage.ts +0 -37
  177. package/src/RedactoPrivacyCenter/lib/utils.refresh-circuit.test.ts +0 -127
  178. package/src/RedactoPrivacyCenter/lib/utils.refresh-storage.test.ts +0 -85
  179. package/src/RedactoPrivacyCenter/lib/utils.session-expired.test.ts +0 -109
  180. package/src/RedactoPrivacyCenter/lib/utils.ts +0 -798
  181. package/src/RedactoPrivacyCenter/locales/as/translation.json +0 -342
  182. package/src/RedactoPrivacyCenter/locales/bn/translation.json +0 -342
  183. package/src/RedactoPrivacyCenter/locales/brx/translation.json +0 -342
  184. package/src/RedactoPrivacyCenter/locales/doi/translation.json +0 -342
  185. package/src/RedactoPrivacyCenter/locales/en/translation.json +0 -357
  186. package/src/RedactoPrivacyCenter/locales/gom/translation.json +0 -342
  187. package/src/RedactoPrivacyCenter/locales/gu/translation.json +0 -342
  188. package/src/RedactoPrivacyCenter/locales/hi/translation.json +0 -345
  189. package/src/RedactoPrivacyCenter/locales/kn/translation.json +0 -342
  190. package/src/RedactoPrivacyCenter/locales/ks/translation.json +0 -342
  191. package/src/RedactoPrivacyCenter/locales/mai/translation.json +0 -342
  192. package/src/RedactoPrivacyCenter/locales/ml/translation.json +0 -342
  193. package/src/RedactoPrivacyCenter/locales/mni-Mtei/translation.json +0 -342
  194. package/src/RedactoPrivacyCenter/locales/mr/translation.json +0 -342
  195. package/src/RedactoPrivacyCenter/locales/ne/translation.json +0 -342
  196. package/src/RedactoPrivacyCenter/locales/or/translation.json +0 -342
  197. package/src/RedactoPrivacyCenter/locales/pa/translation.json +0 -342
  198. package/src/RedactoPrivacyCenter/locales/sa/translation.json +0 -342
  199. package/src/RedactoPrivacyCenter/locales/sat/translation.json +0 -342
  200. package/src/RedactoPrivacyCenter/locales/sd/translation.json +0 -342
  201. package/src/RedactoPrivacyCenter/locales/ta/translation.json +0 -342
  202. package/src/RedactoPrivacyCenter/locales/te/translation.json +0 -342
  203. package/src/RedactoPrivacyCenter/locales/ur/translation.json +0 -342
  204. package/src/RedactoPrivacyCenter/styles/applyBrandingTheme.ts +0 -66
  205. package/src/RedactoPrivacyCenter/styles/base.css +0 -117
  206. package/src/RedactoPrivacyCenter/styles/injectStyles.ts +0 -3108
  207. package/src/RedactoPrivacyCenter/styles/pcStyles.ts +0 -831
  208. package/src/RedactoPrivacyCenter/styles/responsive.ts +0 -138
  209. package/src/RedactoPrivacyCenter/styles/variables.css +0 -96
  210. package/src/RedactoPrivacyCenter/table/AdvancedTable.tsx +0 -387
  211. package/src/RedactoPrivacyCenter/table/AdvancedTablePagination.tsx +0 -468
  212. package/src/RedactoPrivacyCenter/table/index.ts +0 -2
  213. package/src/RedactoPrivacyCenter/types/images.d.ts +0 -29
  214. package/src/RedactoPrivacyCenter/ui/Footer.tsx +0 -69
  215. package/src/RedactoPrivacyCenter/ui/FormBlockWrapper.tsx +0 -54
  216. package/src/RedactoPrivacyCenter/ui/PCAccordion.tsx +0 -93
  217. package/src/RedactoPrivacyCenter/ui/PCActionIcon.tsx +0 -47
  218. package/src/RedactoPrivacyCenter/ui/PCAvatar.test.tsx +0 -83
  219. package/src/RedactoPrivacyCenter/ui/PCAvatar.tsx +0 -93
  220. package/src/RedactoPrivacyCenter/ui/PCBadge.tsx +0 -48
  221. package/src/RedactoPrivacyCenter/ui/PCButton.tsx +0 -77
  222. package/src/RedactoPrivacyCenter/ui/PCCheckbox.tsx +0 -55
  223. package/src/RedactoPrivacyCenter/ui/PCCollapse.tsx +0 -107
  224. package/src/RedactoPrivacyCenter/ui/PCEmpty.tsx +0 -35
  225. package/src/RedactoPrivacyCenter/ui/PCInput.tsx +0 -132
  226. package/src/RedactoPrivacyCenter/ui/PCLoader.tsx +0 -31
  227. package/src/RedactoPrivacyCenter/ui/PCModal.tsx +0 -106
  228. package/src/RedactoPrivacyCenter/ui/PCPopover.tsx +0 -206
  229. package/src/RedactoPrivacyCenter/ui/PCSelect.tsx +0 -433
  230. package/src/RedactoPrivacyCenter/ui/PCTable.tsx +0 -149
  231. package/src/RedactoPrivacyCenter/ui/PCText.tsx +0 -41
  232. package/src/RedactoPrivacyCenter/ui/PCTextarea.tsx +0 -43
  233. package/src/RedactoPrivacyCenter/ui/PCTitle.tsx +0 -37
  234. package/src/RedactoPrivacyCenter/ui/PCTooltip.tsx +0 -121
  235. package/src/RedactoPrivacyCenter/ui/SimpleBar.tsx +0 -25
  236. package/src/RedactoPrivacyCenter/ui/StatusBadge.tsx +0 -53
  237. package/src/RedactoPrivacyCenter/ui/index.ts +0 -18
  238. package/src/RedactoPrivacyCenter/utils/cn.ts +0 -28
  239. package/src/RedactoPrivacyCenter/utils/date.ts +0 -48
  240. package/src/RedactoPrivacyCenter/utils/status.ts +0 -111
  241. package/src/RedactoPrivacyCenter/utils/toast.ts +0 -130
  242. package/src/index.ts +0 -19
  243. package/src/privacy-center.ts +0 -113
  244. package/src/shared/api-errors.ts +0 -180
  245. package/src/shared/notice-consent-status.ts +0 -190
  246. package/src/shared/sandbox.ts +0 -6
  247. package/src/types/css.d.ts +0 -4
  248. package/src/types/images.d.ts +0 -19
  249. package/src/types/react-jsx.d.ts +0 -26
  250. package/tests/DataAvailabilityContext.test.tsx +0 -123
  251. package/tests/Form.test.tsx +0 -1424
  252. package/tests/ManageConsentErrorMapping.test.tsx +0 -85
  253. package/tests/ProductSelectionSection.test.tsx +0 -328
  254. package/tests/RequestSubmit.test.tsx +0 -135
  255. package/tests/RevocablePurpose.test.tsx +0 -146
  256. package/tests/RevokeWarningMessage.test.tsx +0 -151
  257. package/tests/consentClient.test.ts +0 -217
  258. package/tests/manageConsentServer.test.ts +0 -38
  259. package/tests/mocks.ts +0 -257
  260. package/tests/resolveContactFromJwt.test.ts +0 -44
  261. package/tests/setup.ts +0 -16
  262. package/tsconfig.json +0 -16
  263. package/tsup.config.ts +0 -31
  264. package/vitest.config.ts +0 -16
@@ -1,695 +0,0 @@
1
- import type { BaseRequest } from './client';
2
- import { isTerminalRefreshError } from './fetcher';
3
-
4
- export type ConsentApiErrorCode =
5
- | 'NOMINATOR_NOT_FOUND'
6
- | 'NOMINEE_MUST_SPECIFY_NOMINATOR'
7
- | 'PURPOSE_NOT_REVOCABLE';
8
-
9
- export class ConsentApiError extends Error {
10
- code: ConsentApiErrorCode;
11
- constructor(code: ConsentApiErrorCode, message: string) {
12
- super(message);
13
- this.name = 'ConsentApiError';
14
- this.code = code;
15
- }
16
- }
17
-
18
- import type {
19
- ActivityDetail,
20
- CaseActionBaseParams,
21
- CaseHistoryDetail,
22
- CaseMessage,
23
- ConsentAction,
24
- CreateCaseResponse,
25
- FormData,
26
- GetCaseDocumentParams,
27
- GetCaseMessagesParams,
28
- MessageDocument,
29
- GetNotificationsServerParams,
30
- LegacyManageConsentResponse,
31
- NotificationActionBaseParams,
32
- NotificationActionResponse,
33
- NotificationByUuidServerParams,
34
- NotificationClient,
35
- NotificationListResponse,
36
- NotificationSummary,
37
- OtpResponse,
38
- OtpVerificationResponse,
39
- Pagination,
40
- SendCaseMessageParams,
41
- SubmitDocumentForRequestParams,
42
- TokenExchangeResponse,
43
- UnreadCountResponse,
44
- UploadCaseDocumentParams,
45
- UploadDocumentResponse,
46
- UserConsentDetail,
47
- GroupPurposesOut,
48
- } from '../lib/types';
49
-
50
- function buildBaseRequest(organizationId: string, workspaceId: string, authToken?: string): BaseRequest {
51
- return { organisationUuid: organizationId, workspaceUuid: workspaceId, authToken: authToken || '' };
52
- }
53
-
54
- /**
55
- * Check if an error is an authentication/JWT related error
56
- */
57
- function isAuthError(error: any): boolean {
58
- const errorMessage = error?.message || '';
59
- return (
60
- errorMessage.includes('JWT') ||
61
- errorMessage.includes('401') ||
62
- errorMessage.includes('expired') ||
63
- errorMessage.includes('token')
64
- );
65
- }
66
-
67
- /**
68
- * Handle server action errors - re-throws auth errors, logs others
69
- */
70
- function handleServerActionError(
71
- error: any,
72
- errorContext: string,
73
- shouldThrow404 = false
74
- ): null {
75
- // Re-throw auth errors so client can handle refresh
76
- if (isAuthError(error)) {
77
- throw error;
78
- }
79
- console.error(`Error ${errorContext}:`, error);
80
- if (shouldThrow404 && error.message?.includes('404')) {
81
- throw error;
82
- }
83
- return null;
84
- }
85
-
86
- export async function getFormDataServer(
87
- organizationId: string,
88
- workspaceId: string,
89
- contact: string,
90
- authToken?: string,
91
- useSessionAuth?: boolean,
92
- consentClient?: ReturnType<typeof import('./client').createConsentClient>,
93
- language?: string
94
- ): Promise<FormData | null> {
95
- try {
96
- if (!consentClient) {
97
- throw new Error('Consent client is required');
98
- }
99
- const baseRequest = buildBaseRequest(organizationId, workspaceId, authToken);
100
-
101
- // If useSessionAuth is true (case management), use X-Auth-Token
102
- // Otherwise (privacy center), use JWT Bearer token
103
- const result = await consentClient.getFormData(baseRequest, contact, authToken, {
104
- useSessionAuth: useSessionAuth ?? false, // Default to false for privacy center
105
- }, language);
106
- return result as FormData;
107
- } catch (error: any) {
108
- return handleServerActionError(error, 'fetching form data', true);
109
- }
110
- }
111
-
112
- export async function createCaseRequestServer(
113
- organizationId: string,
114
- workspaceId: string,
115
- data: unknown,
116
- authToken?: string,
117
- useSessionAuth?: boolean,
118
- consentClient?: ReturnType<typeof import('./client').createConsentClient>
119
- ): Promise<CreateCaseResponse | null> {
120
- try {
121
- if (!consentClient) {
122
- throw new Error('Consent client is required');
123
- }
124
- const baseRequest = buildBaseRequest(organizationId, workspaceId, authToken);
125
-
126
- // If useSessionAuth is true (case management), use X-Auth-Token
127
- // Otherwise (privacy center), use JWT Bearer token
128
- const result = await consentClient.createCaseRequest(baseRequest, data, authToken, {
129
- useSessionAuth: useSessionAuth ?? false, // Default to false for privacy center
130
- });
131
- return result as CreateCaseResponse;
132
- } catch (error: any) {
133
- return handleServerActionError(error, 'creating case request');
134
- }
135
- }
136
-
137
- export async function createOtpServer(
138
- email: string,
139
- organizationId: string,
140
- workspaceId: string,
141
- consentClient?: ReturnType<typeof import('./client').createConsentClient>
142
- ): Promise<OtpResponse> {
143
- try {
144
- if (!consentClient) {
145
- throw new Error('Consent client is required');
146
- }
147
- const result = await consentClient.createOtp(organizationId, workspaceId, email);
148
- return result as OtpResponse;
149
- } catch (error) {
150
- console.error('Error creating OTP:', error);
151
- throw error;
152
- }
153
- }
154
-
155
- export async function verifyOtpServer(
156
- otpId: string,
157
- otp: string,
158
- organizationId: string,
159
- workspaceId: string,
160
- consentClient?: ReturnType<typeof import('./client').createConsentClient>
161
- ): Promise<OtpVerificationResponse> {
162
- try {
163
- if (!consentClient) {
164
- throw new Error('Consent client is required');
165
- }
166
- const result = await consentClient.verifyOtp(organizationId, workspaceId, otpId, otp);
167
- const response = result as OtpVerificationResponse;
168
- return response;
169
- } catch (error) {
170
- console.error('Error verifying OTP:', error);
171
- throw error;
172
- }
173
- }
174
-
175
- export async function exchangeTokenServer(
176
- token: string,
177
- consentClient?: ReturnType<typeof import('./client').createConsentClient>
178
- ): Promise<TokenExchangeResponse> {
179
- try {
180
- if (!consentClient) {
181
- throw new Error('Consent client is required');
182
- }
183
- const result = await consentClient.exchangeToken(token);
184
- return result as TokenExchangeResponse;
185
- } catch (error) {
186
- console.error('Error exchanging token:', error);
187
- throw error;
188
- }
189
- }
190
-
191
- export async function refreshOtpTokenServer(
192
- organizationId: string,
193
- workspaceId: string,
194
- refreshToken: string,
195
- consentClient?: ReturnType<typeof import('./client').createConsentClient>
196
- ): Promise<OtpResponse | null> {
197
- // Validate refreshToken before making API call
198
- if (!refreshToken || typeof refreshToken !== 'string' || refreshToken.trim() === '') {
199
- console.error('[Token Refresh] Invalid refresh token provided');
200
- return null;
201
- }
202
-
203
- // Validate organizationId and workspaceId
204
- if (!organizationId || !workspaceId) {
205
- console.error('[Token Refresh] Missing organizationId or workspaceId');
206
- return null;
207
- }
208
-
209
- try {
210
- if (!consentClient) {
211
- throw new Error('Consent client is required');
212
- }
213
- const result = await consentClient.refreshOtpToken(
214
- organizationId,
215
- workspaceId,
216
- refreshToken
217
- );
218
-
219
- const response = result as OtpResponse;
220
- // Check if the response indicates failure
221
- if (response && response.success === false) {
222
- // Return null to indicate refresh failed
223
- return null;
224
- }
225
- return response;
226
- } catch (error: any) {
227
- // Terminal token errors (expired / not found / already used / 4xx) are an
228
- // expected outcome — return null so the caller trips the circuit breaker
229
- // instead of treating it as a retryable exception (incident 2026-06-22).
230
- if (isTerminalRefreshError(error)) {
231
- return null;
232
- }
233
-
234
- // Transient errors (network / 5xx): re-throw so the caller can back off + retry.
235
- console.error('Error refreshing token:', error);
236
- throw error;
237
- }
238
- }
239
-
240
- export async function fetchProductsServer(params: {
241
- organizationId: string;
242
- workspaceId: string;
243
- skip?: number;
244
- limit?: number;
245
- authToken?: string;
246
- consentClient?: ReturnType<typeof import('./client').createConsentClient>;
247
- }): Promise<Array<{ uuid: string; name: string; description?: string }> | null> {
248
- try {
249
- if (!params.consentClient) {
250
- throw new Error('Consent client is required');
251
- }
252
- // Privacy center endpoints use JWT Bearer tokens, not session-based auth
253
- const baseRequest = buildBaseRequest(params.organizationId, params.workspaceId, params.authToken);
254
-
255
- const result = await params.consentClient.getProducts(
256
- baseRequest,
257
- params.skip || 0,
258
- params.limit || 100 // Get more products for filter dropdown
259
- );
260
- return (result as { data?: Array<{ uuid: string; name: string; description?: string }> })?.data || [];
261
- } catch (error: any) {
262
- return handleServerActionError(error, 'fetching products');
263
- }
264
- }
265
-
266
- export async function fetchUserConsentsServer(params: {
267
- organizationId: string;
268
- workspaceId: string;
269
- offset?: number;
270
- limit?: number;
271
- nominatedOffset?: number;
272
- nominatedLimit?: number;
273
- search?: string;
274
- status?: string;
275
- product_uuid?: string;
276
- language?: string;
277
- authToken?: string;
278
- consentClient?: ReturnType<typeof import('./client').createConsentClient>;
279
- }): Promise<UserConsentDetail | null> {
280
- try {
281
- if (!params.consentClient) {
282
- throw new Error('Consent client is required');
283
- }
284
- // Privacy center endpoints use JWT Bearer tokens, not session-based auth
285
- const baseRequest = buildBaseRequest(params.organizationId, params.workspaceId, params.authToken);
286
-
287
- const result = await params.consentClient.getUserConsents(
288
- baseRequest,
289
- {
290
- offset: params.offset,
291
- limit: params.limit,
292
- nominated_offset: params.nominatedOffset,
293
- nominated_limit: params.nominatedLimit,
294
- status: params.status,
295
- product_uuid: params.product_uuid,
296
- search: params.search,
297
- language: params.language,
298
- },
299
- params.authToken
300
- );
301
-
302
- return result as UserConsentDetail;
303
- } catch (error: any) {
304
- return handleServerActionError(error, 'fetching user consents');
305
- }
306
- }
307
-
308
- export async function fetchGroupPurposesServer(params: {
309
- organizationId: string;
310
- workspaceId: string;
311
- productUuid: string;
312
- offset?: number;
313
- limit?: number;
314
- status?: string;
315
- search?: string;
316
- language?: string;
317
- nominatorUuid?: string;
318
- authToken?: string;
319
- consentClient?: ReturnType<typeof import('./client').createConsentClient>;
320
- }): Promise<GroupPurposesOut | null> {
321
- try {
322
- if (!params.consentClient) {
323
- throw new Error('Consent client is required');
324
- }
325
- const baseRequest = buildBaseRequest(params.organizationId, params.workspaceId, params.authToken);
326
-
327
- const result = await params.consentClient.getGroupPurposes(
328
- baseRequest,
329
- params.productUuid,
330
- {
331
- offset: params.offset,
332
- limit: params.limit,
333
- status: params.status,
334
- search: params.search,
335
- language: params.language,
336
- nominator_uuid: params.nominatorUuid,
337
- },
338
- params.authToken
339
- );
340
-
341
- return result as GroupPurposesOut;
342
- } catch (error: any) {
343
- return handleServerActionError(error, 'fetching group purposes');
344
- }
345
- }
346
-
347
- export async function manageConsentServer(params: {
348
- organizationId: string;
349
- workspaceId: string;
350
- purposeId: string;
351
- contact: string;
352
- action: ConsentAction;
353
- authToken?: string;
354
- consentClient?: ReturnType<typeof import('./client').createConsentClient>;
355
- nominatorContact?: string;
356
- dataElementUuids?: string[];
357
- productUuid?: string;
358
- noticeUuid?: string;
359
- dataElements?: Array<{ uuid: string; selected: boolean }>;
360
- language?: string;
361
- }): Promise<boolean | null> {
362
- try {
363
- if (!params.consentClient) {
364
- throw new Error('Consent client is required');
365
- }
366
- // Privacy center endpoints use JWT Bearer tokens, not session-based auth
367
- const baseRequest = buildBaseRequest(params.organizationId, params.workspaceId, params.authToken);
368
-
369
- // Ledger mode routes to the Go ledger's submit-consent (partial), which
370
- // resolves on 2xx and throws otherwise — a resolved call is success (the
371
- // ledger returns a ConsentEventResponse, no `success` flag). Legacy mode
372
- // hits the Python manage-consent endpoint, whose unwrapped response
373
- // carries a `success` flag that must be honored even on 2xx.
374
- const result = await params.consentClient.manageConsent(
375
- baseRequest,
376
- params.purposeId,
377
- params.contact,
378
- params.action,
379
- params.authToken,
380
- undefined,
381
- params.nominatorContact,
382
- params.dataElementUuids,
383
- params.productUuid,
384
- params.noticeUuid,
385
- params.dataElements,
386
- params.language
387
- );
388
- if (result && typeof result === 'object' && 'success' in result) {
389
- return Boolean((result as LegacyManageConsentResponse).success);
390
- }
391
- return true;
392
- } catch (error: any) {
393
- // Normalize nominator-specific errors into stable error codes
394
- const errorMsg = error?.message || '';
395
- if (errorMsg.includes('nominator_not_found')) {
396
- throw new ConsentApiError('NOMINATOR_NOT_FOUND', errorMsg);
397
- }
398
- if (errorMsg.includes('nominee_must_specify_nominator')) {
399
- throw new ConsentApiError('NOMINEE_MUST_SPECIFY_NOMINATOR', errorMsg);
400
- }
401
- // The Python renderer nests the app-level code under `detail.code`
402
- // (top-level `code` is the numeric HTTP status); a wrapper or the Go ledger
403
- // may instead surface it at the top level. Read both structured fields
404
- // rather than string-scanning the message.
405
- if (
406
- error?.code === 'purpose_not_revocable' ||
407
- error?.detail?.code === 'purpose_not_revocable'
408
- ) {
409
- throw new ConsentApiError('PURPOSE_NOT_REVOCABLE', errorMsg);
410
- }
411
- return handleServerActionError(error, `${params.action} consent`);
412
- }
413
- }
414
-
415
- export async function fetchActivitiesServer(params: {
416
- organizationId: string;
417
- workspaceId: string;
418
- offset?: number;
419
- limit?: number;
420
- language?: string;
421
- authToken?: string;
422
- consentClient?: ReturnType<typeof import('./client').createConsentClient>;
423
- }): Promise<ActivityDetail | null> {
424
- try {
425
- if (!params.consentClient) {
426
- throw new Error('Consent client is required');
427
- }
428
-
429
- // Privacy center endpoints use JWT Bearer tokens, not session-based auth
430
- const baseRequest = buildBaseRequest(params.organizationId, params.workspaceId, params.authToken);
431
-
432
- const result = await params.consentClient.getActivities(
433
- baseRequest,
434
- params.offset,
435
- params.limit,
436
- params.language,
437
- params.authToken
438
- );
439
- return result as ActivityDetail;
440
- } catch (error: any) {
441
- return handleServerActionError(error, 'fetching activities');
442
- }
443
- }
444
-
445
- export async function fetchReceiptsServer(params: {
446
- organizationId: string;
447
- workspaceId: string;
448
- skip?: number;
449
- limit?: number;
450
- notice_uuid?: string;
451
- event_type?: string;
452
- status?: string;
453
- created_after?: string;
454
- created_before?: string;
455
- language?: string;
456
- authToken?: string;
457
- consentClient?: ReturnType<typeof import('./client').createConsentClient>;
458
- }): Promise<unknown | null> {
459
- try {
460
- if (!params.consentClient) {
461
- throw new Error('Consent client is required');
462
- }
463
- // Privacy center endpoints use JWT Bearer tokens, not session-based auth
464
- const baseRequest = buildBaseRequest(params.organizationId, params.workspaceId, params.authToken);
465
-
466
- const result = await params.consentClient.getReceipts(
467
- baseRequest,
468
- {
469
- skip: params.skip,
470
- limit: params.limit,
471
- notice_uuid: params.notice_uuid,
472
- event_type: params.event_type,
473
- status: params.status,
474
- created_after: params.created_after,
475
- created_before: params.created_before,
476
- language: params.language,
477
- },
478
- params.authToken
479
- );
480
- return result;
481
- } catch (error: any) {
482
- return handleServerActionError(error, 'fetching receipts');
483
- }
484
- }
485
-
486
- export async function fetchReceiptPdfServer(params: {
487
- organizationId: string;
488
- workspaceId: string;
489
- receiptUuid: string;
490
- authToken?: string;
491
- consentClient?: ReturnType<typeof import('./client').createConsentClient>;
492
- }): Promise<Blob | null> {
493
- try {
494
- if (!params.consentClient) {
495
- throw new Error('Consent client is required');
496
- }
497
- const baseRequest = buildBaseRequest(params.organizationId, params.workspaceId, params.authToken);
498
-
499
- const result = await params.consentClient.getReceiptPdf(
500
- baseRequest,
501
- params.receiptUuid,
502
- params.authToken
503
- );
504
- return result;
505
- } catch (error: any) {
506
- // Re-throw 404s (receipt doesn't exist or not yours) so the UI can show a targeted message
507
- return handleServerActionError(error, 'downloading receipt PDF', true);
508
- }
509
- }
510
-
511
- export async function fetchCaseHistoryServer(params: {
512
- organizationId: string;
513
- workspaceId: string;
514
- contact: string;
515
- offset?: number;
516
- limit?: number;
517
- language?: string;
518
- authToken?: string;
519
- consentClient?: ReturnType<typeof import('./client').createConsentClient>;
520
- }): Promise<CaseHistoryDetail | null> {
521
- try {
522
- if (!params.consentClient) {
523
- throw new Error('Consent client is required');
524
- }
525
- // Privacy center endpoints use JWT Bearer tokens, not session-based auth
526
- const baseRequest = buildBaseRequest(params.organizationId, params.workspaceId, params.authToken);
527
-
528
- const result = await params.consentClient.getCaseHistory(
529
- baseRequest,
530
- params.contact,
531
- params.offset,
532
- params.limit,
533
- params.language,
534
- params.authToken
535
- );
536
-
537
- if (Array.isArray(result)) {
538
- return {
539
- data: result,
540
- pagination: {
541
- total_count: result.length,
542
- offset: params.offset || 0,
543
- limit: params.limit || 10
544
- },
545
- } as CaseHistoryDetail;
546
- }
547
-
548
- if (result && typeof result === 'object' && 'data' in result) {
549
- const resultData = result as { data?: unknown[]; pagination?: Pagination };
550
- return {
551
- data: resultData.data || [],
552
- pagination: resultData.pagination || {
553
- total_count: resultData.data?.length || 0,
554
- offset: params.offset || 0,
555
- limit: params.limit || 10
556
- },
557
- } as CaseHistoryDetail;
558
- }
559
-
560
- return {
561
- data: [],
562
- pagination: {
563
- total_count: 0,
564
- offset: params.offset || 0,
565
- limit: params.limit || 10
566
- },
567
- } as CaseHistoryDetail;
568
- } catch (error: any) {
569
- return handleServerActionError(error, 'fetching case history');
570
- }
571
- }
572
-
573
- // ─── Case Communication ──────────────────────────────────────────────────────
574
-
575
- type ConsentClient = NonNullable<CaseActionBaseParams['consentClient']>;
576
-
577
- async function runCaseAction<T>(
578
- params: CaseActionBaseParams,
579
- label: string,
580
- fn: (client: ConsentClient, baseRequest: BaseRequest) => Promise<T>
581
- ): Promise<T | null> {
582
- try {
583
- if (!params.consentClient) throw new Error('Consent client is required');
584
- const baseRequest = buildBaseRequest(params.organizationId, params.workspaceId, params.authToken);
585
- return await fn(params.consentClient, baseRequest);
586
- } catch (error: any) {
587
- return handleServerActionError(error, label);
588
- }
589
- }
590
-
591
- export async function getCaseMessagesServer(params: GetCaseMessagesParams): Promise<CaseMessage[] | null> {
592
- return runCaseAction(params, 'fetching case messages', (client, base) =>
593
- client.getCaseMessages(base, params.caseUuid, params.authToken)
594
- );
595
- }
596
-
597
- export async function sendCaseMessageServer(params: SendCaseMessageParams): Promise<CaseMessage | null> {
598
- return runCaseAction(params, 'sending case message', (client, base) =>
599
- client.sendCaseMessage(base, params.caseUuid, params.body, params.documentUuids, params.authToken)
600
- );
601
- }
602
-
603
- export async function uploadCaseDocumentServer(params: UploadCaseDocumentParams): Promise<UploadDocumentResponse | null> {
604
- return runCaseAction(params, 'uploading case document', (client, base) =>
605
- client.uploadCaseDocument(base, params.caseUuid, params.file, params.authToken)
606
- );
607
- }
608
-
609
- export async function submitDocumentForRequestServer(params: SubmitDocumentForRequestParams): Promise<CaseMessage | null> {
610
- return runCaseAction(params, 'submitting document for request', (client, base) =>
611
- client.submitDocumentForRequest(base, params.caseUuid, params.requestEventUuid, params.documentUuid, params.body, params.authToken)
612
- );
613
- }
614
-
615
- export async function getCaseDocumentServer(params: GetCaseDocumentParams): Promise<MessageDocument | null> {
616
- return runCaseAction(params, 'fetching case document', (client, base) =>
617
- client.getCaseDocument(base, params.caseUuid, params.documentUuid, params.authToken)
618
- );
619
- }
620
-
621
- // ─── Notification Hub ───────────────────────────────────────────────────────
622
-
623
-
624
-
625
- async function runNotificationAction<T>(
626
- params: NotificationActionBaseParams,
627
- label: string,
628
- fn: (client: NotificationClient, baseRequest: BaseRequest) => Promise<T>
629
- ): Promise<T | null> {
630
- try {
631
- if (!params.consentClient) {
632
- throw new Error('Consent client is required')
633
- }
634
- const baseRequest = buildBaseRequest(params.organizationId, params.workspaceId, params.authToken);
635
- return await fn(params.consentClient, baseRequest);
636
- } catch (error) {
637
- return handleServerActionError(error, label);
638
- }
639
- }
640
-
641
- export async function getNotificationsServer(
642
- params: GetNotificationsServerParams
643
- ): Promise<NotificationListResponse | null> {
644
- return runNotificationAction(params, 'fetching notifications', (client, base) =>
645
- client.getNotifications(base, {
646
- category: params.category,
647
- notification_type: params.notification_type,
648
- is_read: params.is_read,
649
- skip: params.skip,
650
- limit: params.limit,
651
- include_summary: params.include_summary,
652
- language: params.language,
653
- }, params.authToken)
654
- );
655
- }
656
-
657
- export async function getNotificationSummaryServer(
658
- params: NotificationActionBaseParams
659
- ): Promise<NotificationSummary | null> {
660
- return runNotificationAction(params, 'fetching notification summary', (client, base) =>
661
- client.getNotificationSummary(base, params.authToken)
662
- );
663
- }
664
-
665
- export async function getUnreadCountServer(
666
- params: NotificationActionBaseParams
667
- ): Promise<UnreadCountResponse | null> {
668
- return runNotificationAction(params, 'fetching unread count', (client, base) =>
669
- client.getUnreadCount(base, params.authToken)
670
- );
671
- }
672
-
673
- export async function markNotificationReadServer(
674
- params: NotificationByUuidServerParams
675
- ): Promise<NotificationActionResponse | null> {
676
- return runNotificationAction(params, 'marking notification as read', (client, base) =>
677
- client.markNotificationRead(base, params.notificationUuid, params.authToken)
678
- );
679
- }
680
-
681
- export async function markAllNotificationsReadServer(
682
- params: NotificationActionBaseParams
683
- ): Promise<NotificationActionResponse | null> {
684
- return runNotificationAction(params, 'marking all notifications as read', (client, base) =>
685
- client.markAllNotificationsRead(base, params.authToken)
686
- );
687
- }
688
-
689
- export async function acknowledgeNotificationServer(
690
- params: NotificationByUuidServerParams
691
- ): Promise<NotificationActionResponse | null> {
692
- return runNotificationAction(params, 'acknowledging notification', (client, base) =>
693
- client.acknowledgeNotification(base, params.notificationUuid, params.authToken)
694
- );
695
- }