@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,151 +0,0 @@
1
- import { render, screen } from '@testing-library/react';
2
- import { describe, it, expect, vi } from 'vitest';
3
-
4
- // react-i18next is an optional peer dep that is not installed in this
5
- // package's node_modules. Stub it with a minimal `useTranslation` that
6
- // resolves the keys used by the components under test, honouring the inline
7
- // English fallback passed as the 2nd argument (mirrors the real i18next
8
- // behaviour when a key is missing).
9
- vi.mock('react-i18next', () => {
10
- const en: Record<string, string> = {
11
- modifyConsent: 'Modify Consent',
12
- closeModal: 'Close',
13
- cancel: 'Cancel',
14
- revokeConsent: 'Revoke Consent',
15
- revokeConsentWarning: 'If you revoke this consent, you may lose access.',
16
- regrantConsent: 'Regrant Consent',
17
- regrantConsentWarning: 'Regranting will restore this consent.',
18
- aboutToModifyConsent: 'You are about to modify this consent.',
19
- aboutToRegrantConsent: 'You are about to regrant this consent.',
20
- noDataElementsAvailable: 'No data elements available',
21
- noActionsAvailable: 'No actions available for this record.',
22
- };
23
- const interpolate = (template: string, vars?: Record<string, unknown>) =>
24
- template.replace(/\{\{(\w+)\}\}/g, (_match, key: string) => {
25
- const value = vars?.[key];
26
- return value === undefined || value === null ? '' : String(value);
27
- });
28
- // Supports the `t(key, fallbackString)` and `t(key, opts)` call shapes used
29
- // across the components. When the key is unknown, fall back to the inline
30
- // English string if one was supplied, otherwise echo the key.
31
- const t = (key: string, second?: unknown, opts?: Record<string, unknown>) => {
32
- const fallback = typeof second === 'string' ? second : undefined;
33
- const interpolationOpts =
34
- typeof second === 'object' && second !== null
35
- ? (second as Record<string, unknown>)
36
- : opts;
37
- const template = en[key] ?? fallback ?? key;
38
- return interpolate(template, interpolationOpts);
39
- };
40
- return {
41
- useTranslation: () => ({ t, i18n: { language: 'en' } }),
42
- };
43
- });
44
-
45
- // Icon peer deps — stub the icons used by the modal.
46
- vi.mock('lucide-react', () => ({
47
- ChevronDownIcon: () => null,
48
- X: () => null,
49
- Smartphone: () => null,
50
- LaptopMinimal: () => null,
51
- }));
52
-
53
- vi.mock('react-icons/pi', () => ({
54
- PiWarningCircleBold: () => null,
55
- }));
56
-
57
- import { ModifyConsentModal } from '../src/RedactoPrivacyCenter/components/ModifyConsentModal';
58
- import { NavigationProvider } from '../src/RedactoPrivacyCenter/context/NavigationContext';
59
- import { ConsentStatusEnum } from '../src/RedactoPrivacyCenter/lib/types';
60
- import type { ConsentModalRecord } from '../src/RedactoPrivacyCenter/lib/types';
61
-
62
- const DEFAULT_WARNING = 'If you revoke this consent, you may lose access.';
63
- const CUSTOM_WARNING =
64
- 'Revoking marketing consent will stop all promotional emails immediately.';
65
-
66
- const makeRecord = (
67
- overrides: Partial<ConsentModalRecord> = {},
68
- ): ConsentModalRecord => ({
69
- purpose_uuid: 'purpose-1',
70
- name: 'Marketing analytics',
71
- description: 'Improve product recommendations',
72
- status: ConsentStatusEnum.ACTIVE,
73
- given_date: '2026-01-01T00:00:00Z',
74
- valid_till: null,
75
- method: 'WEB',
76
- data_elements: [],
77
- link_reason: null,
78
- product_uuid: 'prod-1',
79
- product_name: 'Acme Loyalty',
80
- product_description: null,
81
- nominator: null,
82
- ...overrides,
83
- });
84
-
85
- const renderModal = (record: ConsentModalRecord) =>
86
- render(
87
- <NavigationProvider>
88
- <ModifyConsentModal
89
- isOpen
90
- onClose={vi.fn()}
91
- selectedRecord={record}
92
- isLoading={false}
93
- onManageConsent={vi.fn()}
94
- />
95
- </NavigationProvider>,
96
- );
97
-
98
- describe('per-purpose revoke warning message', () => {
99
- it('shows the custom warning when revoke_warning_message is set on a revoke record', () => {
100
- renderModal(makeRecord({ revoke_warning_message: CUSTOM_WARNING }));
101
-
102
- expect(screen.getByText(CUSTOM_WARNING)).toBeInTheDocument();
103
- // The localized default must be suppressed when a custom message exists.
104
- expect(screen.queryByText(DEFAULT_WARNING)).not.toBeInTheDocument();
105
- // Button label is untouched — still the default revoke copy.
106
- expect(
107
- screen.getByRole('button', { name: 'Revoke Consent' }),
108
- ).toBeInTheDocument();
109
- });
110
-
111
- it('shows the localized default warning when revoke_warning_message is null', () => {
112
- renderModal(makeRecord({ revoke_warning_message: null }));
113
-
114
- expect(screen.getByText(DEFAULT_WARNING)).toBeInTheDocument();
115
- expect(
116
- screen.getByRole('button', { name: 'Revoke Consent' }),
117
- ).toBeInTheDocument();
118
- });
119
-
120
- it('shows the localized default warning when revoke_warning_message is an empty string', () => {
121
- renderModal(makeRecord({ revoke_warning_message: '' }));
122
-
123
- expect(screen.getByText(DEFAULT_WARNING)).toBeInTheDocument();
124
- });
125
-
126
- it('shows the localized default warning when revoke_warning_message is absent (older backends)', () => {
127
- renderModal(makeRecord()); // no `revoke_warning_message` field
128
-
129
- expect(screen.getByText(DEFAULT_WARNING)).toBeInTheDocument();
130
- expect(
131
- screen.getByRole('button', { name: 'Revoke Consent' }),
132
- ).toBeInTheDocument();
133
- });
134
-
135
- it('does not apply the custom revoke warning to the regrant branch', () => {
136
- // A withdrawn record uses the regrant action; the per-purpose revoke
137
- // message must never leak into the regrant warning.
138
- renderModal(
139
- makeRecord({
140
- status: ConsentStatusEnum.WITHDRAWN,
141
- revoke_warning_message: CUSTOM_WARNING,
142
- }),
143
- );
144
-
145
- expect(screen.getByText('Regranting will restore this consent.')).toBeInTheDocument();
146
- expect(screen.queryByText(CUSTOM_WARNING)).not.toBeInTheDocument();
147
- expect(
148
- screen.getByRole('button', { name: 'Regrant Consent' }),
149
- ).toBeInTheDocument();
150
- });
151
- });
@@ -1,217 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
-
3
- import { createConsentClient } from '../src/RedactoPrivacyCenter/api/client';
4
- import type { BaseRequest } from '../src/RedactoPrivacyCenter/api/client';
5
-
6
- // URL routing contract for the five consent read/write methods that moved to
7
- // the Go ledger in PR #438. With a ledgerBaseUrl they must hit the ledger's
8
- // /public/... paths; without one they must fall back to the legacy Python
9
- // /dsar/privacy-center paths (prod has no ledger — see PR #438/#460 regression
10
- // where the silent baseUrl fallback 404'd the Privacy Center).
11
-
12
- const BASE_URL = 'https://consent.test';
13
- const LEDGER_URL = 'https://ledger.test/consent-ledger';
14
- const LEGACY_PREFIX =
15
- 'https://consent.test/organisations/org-1/workspaces/ws-1/dsar/privacy-center';
16
- const LEDGER_PREFIX =
17
- 'https://ledger.test/consent-ledger/public/organisations/org-1/workspaces/ws-1';
18
-
19
- const baseRequest: BaseRequest = {
20
- organisationUuid: 'org-1',
21
- workspaceUuid: 'ws-1',
22
- authToken: 'jwt-token',
23
- };
24
-
25
- const jsonResponse = () =>
26
- new Response(JSON.stringify({}), {
27
- status: 200,
28
- headers: { 'Content-Type': 'application/json' },
29
- });
30
-
31
- const pdfResponse = () =>
32
- new Response(new Blob(['%PDF'], { type: 'application/pdf' }), {
33
- status: 200,
34
- headers: { 'Content-Type': 'application/pdf' },
35
- });
36
-
37
- const mockFetch = vi.fn();
38
-
39
- const fetchedUrl = (): string => String(mockFetch.mock.calls[0]?.[0]);
40
-
41
- const fetchedBody = (): Record<string, unknown> =>
42
- JSON.parse(String(mockFetch.mock.calls[0]?.[1]?.body)) as Record<
43
- string,
44
- unknown
45
- >;
46
-
47
- beforeEach(() => {
48
- mockFetch.mockReset();
49
- mockFetch.mockImplementation(() => Promise.resolve(jsonResponse()));
50
- vi.stubGlobal('fetch', mockFetch);
51
- });
52
-
53
- afterEach(() => {
54
- vi.unstubAllGlobals();
55
- });
56
-
57
- describe('createConsentClient — legacy mode (no ledgerBaseUrl)', () => {
58
- const client = createConsentClient(BASE_URL);
59
-
60
- it('routes getUserConsents to the legacy dsar/privacy-center path', async () => {
61
- await client.getUserConsents(baseRequest, { offset: 0, limit: 10 });
62
- expect(fetchedUrl()).toBe(
63
- `${LEGACY_PREFIX}/user-consents?offset=0&limit=10`,
64
- );
65
- });
66
-
67
- it('routes getGroupPurposes to the legacy dsar/privacy-center path', async () => {
68
- await client.getGroupPurposes(baseRequest, 'prod-1', { limit: 5 });
69
- expect(fetchedUrl()).toBe(
70
- `${LEGACY_PREFIX}/user-consents/prod-1/purposes?limit=5`,
71
- );
72
- });
73
-
74
- it('routes manageConsent to the legacy manage-consent endpoint with the legacy body and no noticeUuid requirement', async () => {
75
- await client.manageConsent(
76
- baseRequest,
77
- 'purp-1',
78
- 'jane@example.com',
79
- 'revoke',
80
- undefined,
81
- undefined,
82
- 'nominator@example.com',
83
- ['de-1'],
84
- 'prod-1',
85
- );
86
- expect(fetchedUrl()).toBe(`${LEGACY_PREFIX}/manage-consent?status=revoke`);
87
- expect(fetchedBody()).toEqual({
88
- purpose_uuid: 'purp-1',
89
- contact: 'jane@example.com',
90
- nominator_contact: 'nominator@example.com',
91
- data_element_uuids: ['de-1'],
92
- product_uuid: 'prod-1',
93
- });
94
- });
95
-
96
- it('records the selected language in the legacy manage-consent body', async () => {
97
- await client.manageConsent(
98
- baseRequest,
99
- 'purp-1',
100
- 'jane@example.com',
101
- 'revoke',
102
- undefined,
103
- undefined,
104
- undefined,
105
- undefined,
106
- undefined,
107
- undefined,
108
- undefined,
109
- 'doi',
110
- );
111
- expect(fetchedBody()).toMatchObject({ language: 'doi' });
112
- });
113
-
114
- it('routes getReceipts to the legacy dsar/privacy-center path', async () => {
115
- await client.getReceipts(baseRequest, { skip: 0, limit: 10 });
116
- expect(fetchedUrl()).toBe(`${LEGACY_PREFIX}/receipts?skip=0&limit=10`);
117
- });
118
-
119
- it('routes getReceiptPdf to the legacy /pdf path', async () => {
120
- mockFetch.mockImplementation(() => Promise.resolve(pdfResponse()));
121
- await client.getReceiptPdf(baseRequest, 'r-1');
122
- expect(fetchedUrl()).toBe(`${LEGACY_PREFIX}/receipts/r-1/pdf`);
123
- });
124
-
125
- it('appends the language query param to getActivities when provided', async () => {
126
- await client.getActivities(baseRequest, 0, 15, 'doi');
127
- expect(fetchedUrl()).toContain('language=doi');
128
- });
129
-
130
- it('omits the language query param from getActivities for the default language', async () => {
131
- await client.getActivities(baseRequest, 0, 15);
132
- expect(fetchedUrl()).not.toContain('language=');
133
- });
134
- });
135
-
136
- describe('createConsentClient — ledger mode (ledgerBaseUrl set)', () => {
137
- // Trailing slash must be trimmed from the configured ledger base.
138
- const client = createConsentClient(BASE_URL, `${LEDGER_URL}/`);
139
-
140
- it('routes getUserConsents to the ledger public path', async () => {
141
- await client.getUserConsents(baseRequest, { offset: 0, limit: 10 });
142
- expect(fetchedUrl()).toBe(
143
- `${LEDGER_PREFIX}/user-consents?offset=0&limit=10`,
144
- );
145
- });
146
-
147
- it('routes getGroupPurposes to the ledger public path', async () => {
148
- await client.getGroupPurposes(baseRequest, 'prod-1', { limit: 5 });
149
- expect(fetchedUrl()).toBe(
150
- `${LEDGER_PREFIX}/user-consents/prod-1/purposes?limit=5`,
151
- );
152
- });
153
-
154
- it('routes manageConsent to the ledger submit-consent with a partial payload', async () => {
155
- await client.manageConsent(
156
- baseRequest,
157
- 'purp-1',
158
- 'jane@example.com',
159
- 'revoke',
160
- undefined,
161
- undefined,
162
- undefined,
163
- undefined,
164
- undefined,
165
- 'notice-1',
166
- [{ uuid: 'de-1', selected: true }],
167
- );
168
- expect(fetchedUrl()).toBe(`${LEDGER_PREFIX}/submit-consent`);
169
- expect(fetchedBody()).toMatchObject({
170
- notice_uuid: 'notice-1',
171
- partial: true,
172
- purposes: [
173
- {
174
- purpose_uuid: 'purp-1',
175
- selected: false,
176
- data_elements: [{ uuid: 'de-1', selected: false }],
177
- },
178
- ],
179
- });
180
- });
181
-
182
- it('records the selected language in the ledger partial submit body', async () => {
183
- await client.manageConsent(
184
- baseRequest,
185
- 'purp-1',
186
- 'jane@example.com',
187
- 'revoke',
188
- undefined,
189
- undefined,
190
- undefined,
191
- undefined,
192
- undefined,
193
- 'notice-1',
194
- [{ uuid: 'de-1', selected: true }],
195
- 'doi',
196
- );
197
- expect(fetchedBody()).toMatchObject({ language: 'doi' });
198
- });
199
-
200
- it('throws from manageConsent when noticeUuid is missing', async () => {
201
- await expect(
202
- client.manageConsent(baseRequest, 'purp-1', 'jane@example.com', 'revoke'),
203
- ).rejects.toThrow('notice_uuid is required');
204
- expect(mockFetch).not.toHaveBeenCalled();
205
- });
206
-
207
- it('routes getReceipts to the ledger public path', async () => {
208
- await client.getReceipts(baseRequest, { skip: 0, limit: 10 });
209
- expect(fetchedUrl()).toBe(`${LEDGER_PREFIX}/receipts?skip=0&limit=10`);
210
- });
211
-
212
- it('routes getReceiptPdf to the ledger /download path', async () => {
213
- mockFetch.mockImplementation(() => Promise.resolve(pdfResponse()));
214
- await client.getReceiptPdf(baseRequest, 'r-1');
215
- expect(fetchedUrl()).toBe(`${LEDGER_PREFIX}/receipts/r-1/download`);
216
- });
217
- });
@@ -1,38 +0,0 @@
1
- import { describe, expect, it, vi } from 'vitest';
2
-
3
- import { manageConsentServer } from '../src/RedactoPrivacyCenter/api/actions';
4
- import type { createConsentClient } from '../src/RedactoPrivacyCenter/api/client';
5
-
6
- // manageConsentServer must honor the legacy Python response's `success` flag
7
- // (a 200 with { success: false } is a failure) while still treating the Go
8
- // ledger's ConsentEventResponse (no `success` key) as resolved-on-2xx.
9
-
10
- type ConsentClient = ReturnType<typeof createConsentClient>;
11
-
12
- const makeParams = (result: unknown) => ({
13
- organizationId: 'org-1',
14
- workspaceId: 'ws-1',
15
- purposeId: 'purp-1',
16
- contact: 'jane@example.com',
17
- action: 'revoke' as const,
18
- authToken: 'jwt-token',
19
- consentClient: {
20
- manageConsent: vi.fn().mockResolvedValue(result),
21
- } as unknown as ConsentClient,
22
- });
23
-
24
- describe('manageConsentServer success detection', () => {
25
- it('returns false for a legacy { success: false } response', async () => {
26
- await expect(manageConsentServer(makeParams({ success: false }))).resolves.toBe(false);
27
- });
28
-
29
- it('returns true for a legacy { success: true } response', async () => {
30
- await expect(manageConsentServer(makeParams({ success: true }))).resolves.toBe(true);
31
- });
32
-
33
- it('returns true for a ledger ConsentEventResponse (no success flag)', async () => {
34
- await expect(
35
- manageConsentServer(makeParams({ consent_event_uuid: 'evt-1' })),
36
- ).resolves.toBe(true);
37
- });
38
- });
package/tests/mocks.ts DELETED
@@ -1,257 +0,0 @@
1
- import type { ConsentContent } from "../src/RedactoNoticeConsent/api/types";
2
- import { vi } from "vitest";
3
-
4
- export const mockConsentContent: ConsentContent = {
5
- code: 200,
6
- status: "success",
7
- detail: {
8
- uuid: "notice-123",
9
- name: "Privacy Notice",
10
- organisation_uuid: "org-123",
11
- workspace_uuid: "workspace-123",
12
- collection_point_uuids: [],
13
- collection_points: [],
14
- active_config: {
15
- uuid: "config-123",
16
- notice_uuid: "notice-123",
17
- organisation_uuid: "org-123",
18
- workspace_uuid: "workspace-123",
19
- version: 1,
20
- status: "active",
21
- notice_text: "We care about your privacy.",
22
- additional_text: "",
23
- confirm_button_text: "Accept",
24
- decline_button_text: "Decline",
25
- logo_url: "https://example.com/logo.png",
26
- privacy_policy_url: "https://example.com/privacy",
27
- privacy_center_url: "https://example.com/privacy-center",
28
- primary_color: "#4f87ff",
29
- secondary_color: "#ffffff",
30
- font_preference: "Arial",
31
- privacy_policy_prefix_text: "",
32
- privacy_policy_anchor_text: "Privacy Policy",
33
- privacy_center_anchor_text: "Privacy Center",
34
- purpose_section_heading: "Manage Consent",
35
- notice_banner_heading: "Privacy Notice",
36
- dpo_info: {
37
- grievance_text: "If you have any grievances related to data processing,",
38
- grievance_anchor_text: "click here",
39
- grievance_url: "https://example.com/grievance",
40
- grievance_email: "grievance@example.com",
41
- grievance_email_connector_text: "or email to",
42
- dp_board_text: "In case we were not able to resolve your grievance, you can reach out to the Data Protection Board",
43
- dp_board_anchor_text: "here",
44
- dp_board_url: "https://example.com/dp-board",
45
- dpo_text: "To connect with the Data Protection Officer,",
46
- dpo_anchor_text: "Click here",
47
- dpo_url: "https://example.com/dpo",
48
- },
49
- created_at: "2023-01-01T00:00:00Z",
50
- updated_at: "2023-01-01T00:00:00Z",
51
- deployed_at: "2023-01-01T00:00:00Z",
52
- supported_languages_and_translations: {
53
- es: {
54
- notice_text: "Nos importa tu privacidad.",
55
- additional_text: "",
56
- privacy_policy_prefix_text: "",
57
- privacy_policy_anchor_text: "Política de Privacidad",
58
- confirm_button_text: "Aceptar",
59
- decline_button_text: "Rechazar",
60
- purpose_section_heading: "Gestionar Consentimiento",
61
- notice_banner_heading: "Aviso de Privacidad",
62
- privacy_center_anchor_text: "Centro de Privacidad",
63
- purposes: {
64
- "purpose-1": { name: "Marketing", description: "Usamos datos para marketing." },
65
- },
66
- data_elements: {
67
- "element-1": "Email",
68
- "element-2": "Phone",
69
- },
70
- dpo_info: {
71
- grievance_text: "Si tiene alguna queja relacionada con el procesamiento de datos,",
72
- grievance_anchor_text: "haga clic aquí",
73
- grievance_email_connector_text: "o envíe un correo a",
74
- dp_board_text: "En caso de que no hayamos podido resolver su queja, puede comunicarse con la Junta de Protección de Datos",
75
- dp_board_anchor_text: "aquí",
76
- dpo_text: "Para comunicarse con el Oficial de Protección de Datos,",
77
- dpo_anchor_text: "Haga clic aquí",
78
- },
79
- },
80
- },
81
- purposes: [
82
- {
83
- uuid: "purpose-1",
84
- name: "Marketing",
85
- description: "We use data for marketing purposes.",
86
- industries: "Marketing",
87
- data_elements: [
88
- {
89
- uuid: "element-1",
90
- name: "Email",
91
- required: false,
92
- description: null,
93
- industries: null,
94
- enabled: true,
95
- },
96
- {
97
- uuid: "element-2",
98
- name: "Phone",
99
- required: true,
100
- description: null,
101
- industries: null,
102
- enabled: true,
103
- },
104
- ],
105
- },
106
- ],
107
- default_language: "en",
108
- },
109
- created_at: "2023-01-01T00:00:00Z",
110
- updated_at: "2023-01-01T00:00:00Z",
111
- },
112
- } as const;
113
-
114
- export const mockReconsentContent: ConsentContent = {
115
- ...mockConsentContent,
116
- detail: {
117
- ...mockConsentContent.detail,
118
- reconsent_required: true,
119
- active_config: {
120
- ...mockConsentContent.detail.active_config,
121
- purposes: [
122
- {
123
- uuid: "purpose-1",
124
- name: "Marketing",
125
- description: "We use data for marketing purposes.",
126
- industries: "Marketing",
127
- data_elements: [
128
- {
129
- uuid: "element-1",
130
- name: "Email",
131
- required: false,
132
- description: null,
133
- industries: null,
134
- enabled: true,
135
- },
136
- {
137
- uuid: "element-2",
138
- name: "Phone",
139
- required: true,
140
- description: null,
141
- industries: null,
142
- enabled: true,
143
- },
144
- ],
145
- },
146
- {
147
- uuid: "purpose-2",
148
- name: "Analytics",
149
- description: "We use data for analytics purposes.",
150
- industries: "Analytics",
151
- data_elements: [
152
- {
153
- uuid: "element-3",
154
- name: "Usage Data",
155
- required: false,
156
- description: null,
157
- industries: null,
158
- enabled: true,
159
- },
160
- ],
161
- },
162
- ],
163
- },
164
- purpose_selections: {
165
- "purpose-1": {
166
- selected: true,
167
- status: "ACTIVE",
168
- needs_reconsent: false,
169
- data_elements: {
170
- "element-1": {
171
- selected: true,
172
- enabled: true,
173
- required: false,
174
- },
175
- "element-2": {
176
- selected: true,
177
- enabled: true,
178
- required: true,
179
- },
180
- },
181
- },
182
- "purpose-2": {
183
- selected: false,
184
- status: "EXPIRED",
185
- needs_reconsent: true,
186
- data_elements: {
187
- "element-3": {
188
- selected: false,
189
- enabled: true,
190
- required: false,
191
- },
192
- },
193
- },
194
- },
195
- },
196
- } as const;
197
-
198
- export const mockMagicLinkContent: ConsentContent = {
199
- ...mockConsentContent,
200
- detail: {
201
- ...mockConsentContent.detail,
202
- reconsent_required: false,
203
- purpose_selections: {
204
- "purpose-1": {
205
- selected: true,
206
- status: "ACTIVE",
207
- needs_reconsent: false,
208
- data_elements: {
209
- "element-1": {
210
- selected: true,
211
- enabled: true,
212
- required: false,
213
- },
214
- "element-2": {
215
- selected: true,
216
- enabled: true,
217
- required: true,
218
- },
219
- },
220
- },
221
- },
222
- },
223
- } as const;
224
-
225
- export const mockMinorConsentContent: ConsentContent = {
226
- ...mockConsentContent,
227
- detail: {
228
- ...mockConsentContent.detail,
229
- is_minor: true,
230
- },
231
- } as const;
232
-
233
- export const defaultProps = {
234
- noticeId: "notice-123",
235
- org_uuid: "org-123",
236
- workspace_uuid: "workspace-123",
237
- notice_uuid: "notice-123",
238
- ledgerBaseUrl: "https://ledger.test/consent-ledger",
239
- accessToken: "mock-token",
240
- refreshToken: "mock-refresh-token",
241
- language: "en",
242
- onAccept: vi.fn(),
243
- onDecline: vi.fn(),
244
- onError: vi.fn(),
245
- settings: {
246
- borderRadius: "8px",
247
- backgroundColor: "#ffffff",
248
- headingColor: "#101828",
249
- textColor: "#344054",
250
- button: {
251
- accept: { backgroundColor: "#4f87ff", textColor: "#ffffff" },
252
- decline: { backgroundColor: "#ffffff", textColor: "#000000" },
253
- language: { backgroundColor: "#ffffff", textColor: "#344054" },
254
- },
255
- link: "#4f87ff",
256
- },
257
- } as const;