@redacto.io/consent-sdk-react 10.0.0-beta.8 → 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 (262) 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/{chunk-6A665OPR.mjs → chunk-OGL6OC3A.mjs} +4 -0
  5. package/dist/fonts.d.mts +35 -0
  6. package/dist/fonts.d.ts +35 -0
  7. package/dist/fonts.js +183 -0
  8. package/dist/fonts.mjs +10 -0
  9. package/dist/index.d.mts +41 -4
  10. package/dist/index.d.ts +41 -4
  11. package/dist/index.js +881 -416
  12. package/dist/index.mjs +502 -253
  13. package/dist/montserrat.generated-NBTECYRW.mjs +22 -0
  14. package/dist/privacy-center.d.mts +51 -11
  15. package/dist/privacy-center.d.ts +51 -11
  16. package/dist/privacy-center.js +252 -136
  17. package/dist/privacy-center.mjs +251 -137
  18. package/dist/types-6Aj7faxL.d.mts +57 -0
  19. package/dist/types-6Aj7faxL.d.ts +57 -0
  20. package/package.json +10 -1
  21. package/.turbo/turbo-build.log +0 -22
  22. package/.turbo/turbo-test.log +0 -203
  23. package/.turbo/turbo-verify-pack.log +0 -6
  24. package/CHANGELOG.md +0 -343
  25. package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.test.tsx +0 -934
  26. package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.tsx +0 -2160
  27. package/src/RedactoNoticeAssisted/api/index.ts +0 -275
  28. package/src/RedactoNoticeAssisted/api/types.ts +0 -182
  29. package/src/RedactoNoticeAssisted/assets/redacto-logo.png +0 -0
  30. package/src/RedactoNoticeAssisted/constants.ts +0 -51
  31. package/src/RedactoNoticeAssisted/i18n.ts +0 -1408
  32. package/src/RedactoNoticeAssisted/index.ts +0 -1
  33. package/src/RedactoNoticeAssisted/injectStyles.ts +0 -251
  34. package/src/RedactoNoticeAssisted/styles.ts +0 -730
  35. package/src/RedactoNoticeAssisted/types.ts +0 -26
  36. package/src/RedactoNoticeAssisted/useMediaQuery.ts +0 -36
  37. package/src/RedactoNoticeConsent/RedactoNoticeConsent.test.tsx +0 -1152
  38. package/src/RedactoNoticeConsent/RedactoNoticeConsent.tsx +0 -4258
  39. package/src/RedactoNoticeConsent/api/index.ts +0 -512
  40. package/src/RedactoNoticeConsent/api/types.ts +0 -469
  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 -54
  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 -58
  71. package/src/RedactoPrivacyCenter/api/actions.ts +0 -695
  72. package/src/RedactoPrivacyCenter/api/client.ts +0 -911
  73. package/src/RedactoPrivacyCenter/api/config.ts +0 -33
  74. package/src/RedactoPrivacyCenter/api/fetcher.ts +0 -260
  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 -1796
  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 -187
  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 -119
  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 -160
  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 -19
  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 -276
  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/types.ts +0 -876
  175. package/src/RedactoPrivacyCenter/lib/useCurrentLanguage.ts +0 -37
  176. package/src/RedactoPrivacyCenter/lib/utils.refresh-circuit.test.ts +0 -127
  177. package/src/RedactoPrivacyCenter/lib/utils.refresh-storage.test.ts +0 -85
  178. package/src/RedactoPrivacyCenter/lib/utils.session-expired.test.ts +0 -109
  179. package/src/RedactoPrivacyCenter/lib/utils.ts +0 -783
  180. package/src/RedactoPrivacyCenter/locales/as/translation.json +0 -342
  181. package/src/RedactoPrivacyCenter/locales/bn/translation.json +0 -342
  182. package/src/RedactoPrivacyCenter/locales/brx/translation.json +0 -342
  183. package/src/RedactoPrivacyCenter/locales/doi/translation.json +0 -342
  184. package/src/RedactoPrivacyCenter/locales/en/translation.json +0 -357
  185. package/src/RedactoPrivacyCenter/locales/gom/translation.json +0 -342
  186. package/src/RedactoPrivacyCenter/locales/gu/translation.json +0 -342
  187. package/src/RedactoPrivacyCenter/locales/hi/translation.json +0 -345
  188. package/src/RedactoPrivacyCenter/locales/kn/translation.json +0 -342
  189. package/src/RedactoPrivacyCenter/locales/ks/translation.json +0 -342
  190. package/src/RedactoPrivacyCenter/locales/mai/translation.json +0 -342
  191. package/src/RedactoPrivacyCenter/locales/ml/translation.json +0 -342
  192. package/src/RedactoPrivacyCenter/locales/mni-Mtei/translation.json +0 -342
  193. package/src/RedactoPrivacyCenter/locales/mr/translation.json +0 -342
  194. package/src/RedactoPrivacyCenter/locales/ne/translation.json +0 -342
  195. package/src/RedactoPrivacyCenter/locales/or/translation.json +0 -342
  196. package/src/RedactoPrivacyCenter/locales/pa/translation.json +0 -342
  197. package/src/RedactoPrivacyCenter/locales/sa/translation.json +0 -342
  198. package/src/RedactoPrivacyCenter/locales/sat/translation.json +0 -342
  199. package/src/RedactoPrivacyCenter/locales/sd/translation.json +0 -342
  200. package/src/RedactoPrivacyCenter/locales/ta/translation.json +0 -342
  201. package/src/RedactoPrivacyCenter/locales/te/translation.json +0 -342
  202. package/src/RedactoPrivacyCenter/locales/ur/translation.json +0 -342
  203. package/src/RedactoPrivacyCenter/styles/applyBrandingTheme.ts +0 -66
  204. package/src/RedactoPrivacyCenter/styles/base.css +0 -117
  205. package/src/RedactoPrivacyCenter/styles/injectStyles.ts +0 -3108
  206. package/src/RedactoPrivacyCenter/styles/pcStyles.ts +0 -831
  207. package/src/RedactoPrivacyCenter/styles/responsive.ts +0 -138
  208. package/src/RedactoPrivacyCenter/styles/variables.css +0 -96
  209. package/src/RedactoPrivacyCenter/table/AdvancedTable.tsx +0 -387
  210. package/src/RedactoPrivacyCenter/table/AdvancedTablePagination.tsx +0 -468
  211. package/src/RedactoPrivacyCenter/table/index.ts +0 -2
  212. package/src/RedactoPrivacyCenter/types/images.d.ts +0 -29
  213. package/src/RedactoPrivacyCenter/ui/Footer.tsx +0 -69
  214. package/src/RedactoPrivacyCenter/ui/FormBlockWrapper.tsx +0 -54
  215. package/src/RedactoPrivacyCenter/ui/PCAccordion.tsx +0 -93
  216. package/src/RedactoPrivacyCenter/ui/PCActionIcon.tsx +0 -47
  217. package/src/RedactoPrivacyCenter/ui/PCAvatar.test.tsx +0 -83
  218. package/src/RedactoPrivacyCenter/ui/PCAvatar.tsx +0 -93
  219. package/src/RedactoPrivacyCenter/ui/PCBadge.tsx +0 -48
  220. package/src/RedactoPrivacyCenter/ui/PCButton.tsx +0 -77
  221. package/src/RedactoPrivacyCenter/ui/PCCheckbox.tsx +0 -55
  222. package/src/RedactoPrivacyCenter/ui/PCCollapse.tsx +0 -107
  223. package/src/RedactoPrivacyCenter/ui/PCEmpty.tsx +0 -35
  224. package/src/RedactoPrivacyCenter/ui/PCInput.tsx +0 -132
  225. package/src/RedactoPrivacyCenter/ui/PCLoader.tsx +0 -31
  226. package/src/RedactoPrivacyCenter/ui/PCModal.tsx +0 -106
  227. package/src/RedactoPrivacyCenter/ui/PCPopover.tsx +0 -206
  228. package/src/RedactoPrivacyCenter/ui/PCSelect.tsx +0 -433
  229. package/src/RedactoPrivacyCenter/ui/PCTable.tsx +0 -149
  230. package/src/RedactoPrivacyCenter/ui/PCText.tsx +0 -41
  231. package/src/RedactoPrivacyCenter/ui/PCTextarea.tsx +0 -43
  232. package/src/RedactoPrivacyCenter/ui/PCTitle.tsx +0 -37
  233. package/src/RedactoPrivacyCenter/ui/PCTooltip.tsx +0 -121
  234. package/src/RedactoPrivacyCenter/ui/SimpleBar.tsx +0 -25
  235. package/src/RedactoPrivacyCenter/ui/StatusBadge.tsx +0 -53
  236. package/src/RedactoPrivacyCenter/ui/index.ts +0 -18
  237. package/src/RedactoPrivacyCenter/utils/cn.ts +0 -28
  238. package/src/RedactoPrivacyCenter/utils/date.ts +0 -48
  239. package/src/RedactoPrivacyCenter/utils/status.ts +0 -111
  240. package/src/RedactoPrivacyCenter/utils/toast.ts +0 -130
  241. package/src/index.ts +0 -19
  242. package/src/privacy-center.ts +0 -113
  243. package/src/shared/api-errors.ts +0 -180
  244. package/src/shared/notice-consent-status.ts +0 -190
  245. package/src/types/css.d.ts +0 -4
  246. package/src/types/images.d.ts +0 -19
  247. package/src/types/react-jsx.d.ts +0 -26
  248. package/tests/DataAvailabilityContext.test.tsx +0 -123
  249. package/tests/Form.test.tsx +0 -1287
  250. package/tests/ManageConsentErrorMapping.test.tsx +0 -85
  251. package/tests/ProductSelectionSection.test.tsx +0 -328
  252. package/tests/RequestSubmit.test.tsx +0 -135
  253. package/tests/RevocablePurpose.test.tsx +0 -146
  254. package/tests/RevokeWarningMessage.test.tsx +0 -151
  255. package/tests/consentClient.test.ts +0 -217
  256. package/tests/manageConsentServer.test.ts +0 -38
  257. package/tests/mocks.ts +0 -257
  258. package/tests/resolveContactFromJwt.test.ts +0 -44
  259. package/tests/setup.ts +0 -16
  260. package/tsconfig.json +0 -16
  261. package/tsup.config.ts +0 -31
  262. package/vitest.config.ts +0 -16
@@ -1,25 +0,0 @@
1
- /**
2
- * Unified table and pagination configuration constants
3
- */
4
-
5
- export const DEFAULT_PAGE = 1;
6
- export const DEFAULT_PAGE_SIZE = 10;
7
- export const INITIAL_PAGE = 1;
8
- export const INITIAL_PAGE_SIZE = 10;
9
-
10
- export const PAGE_SIZE_OPTIONS = [
11
- { value: 10, label: '10' },
12
- { value: 15, label: '15' },
13
- { value: 20, label: '20' },
14
- { value: 25, label: '25' },
15
- { value: 50, label: '50' },
16
- { value: 100, label: '100' },
17
- ] as const;
18
-
19
- export const TABLE_CONFIG = {
20
- pageSize: DEFAULT_PAGE_SIZE,
21
- maxDisplayPurposes: 3,
22
- } as const;
23
-
24
- export const SEARCH_DEBOUNCE_DELAY = 500;
25
- export const SKELETON_ROW_COUNT = 5;
@@ -1,160 +0,0 @@
1
- import { createContext, useContext, useState, useEffect, useCallback, useMemo, type ReactNode } from 'react';
2
- import { setRefreshTokenCookie, decodeJwtToken, resolveContactFromJwt, setSessionExpiredListener } from '../lib/utils';
3
- import type { AuthContextValue } from './types';
4
-
5
- export type { AuthContextValue } from './types';
6
-
7
- const AuthContext = createContext<AuthContextValue | null>(null);
8
-
9
- interface AuthProviderProps {
10
- children: ReactNode;
11
- accessToken: string;
12
- refreshToken: string;
13
- onError: (error: Error) => boolean;
14
- }
15
-
16
- /**
17
- * Extract and store organization/auth data from JWT token to sessionStorage
18
- * This makes the SDK self-sufficient - it doesn't depend on host app to set these values
19
- */
20
- const syncJwtDataToSessionStorage = (accessToken: string): void => {
21
- if (typeof window === 'undefined') return;
22
-
23
- const decoded = decodeJwtToken(accessToken);
24
- if (!decoded) {
25
- return;
26
- }
27
-
28
- // Resolve the user's contact identifier (email, or mobile/org_user_id for
29
- // mobile-only logins) so case + consent-management actions have a subject.
30
- // Falls back to previously stored values when the token omits identifiers.
31
- const contact = resolveContactFromJwt(decoded)
32
- || sessionStorage.getItem('email')
33
- || (typeof localStorage !== 'undefined' ? localStorage.getItem('userEmail') : null);
34
- if (contact && typeof contact === 'string') {
35
- sessionStorage.setItem('email', contact);
36
- }
37
-
38
- // Extract organization UUID
39
- const orgUuid = decoded.organisation_uuid;
40
- if (orgUuid && typeof orgUuid === 'string') {
41
- sessionStorage.setItem('pc_org_id', orgUuid);
42
- }
43
-
44
- // Extract workspace UUID
45
- const workspaceUuid = decoded.workspace_uuid;
46
- if (workspaceUuid && typeof workspaceUuid === 'string') {
47
- sessionStorage.setItem('pc_workspace_id', workspaceUuid);
48
- }
49
-
50
- // Extract organization slug
51
- const orgSlug = decoded.organisation_slug;
52
- if (orgSlug && typeof orgSlug === 'string') {
53
- sessionStorage.setItem('pc_org_slug', orgSlug);
54
- }
55
- };
56
-
57
- export const AuthProvider = ({
58
- children,
59
- accessToken: initialAccessToken,
60
- refreshToken: initialRefreshToken,
61
- onError,
62
- }: AuthProviderProps) => {
63
- // Sync to sessionStorage synchronously during initialization so child
64
- // components (ConsentManager, SideBarPC) find the data when they mount.
65
- // useEffect runs AFTER children render — too late for components that
66
- // read sessionStorage during their render phase.
67
- const [accessToken, setAccessToken] = useState(() => {
68
- if (initialAccessToken && typeof initialAccessToken === 'string' && initialAccessToken.trim() !== '') {
69
- if (typeof window !== 'undefined') {
70
- sessionStorage.setItem('access_token', initialAccessToken);
71
- syncJwtDataToSessionStorage(initialAccessToken);
72
- }
73
- }
74
- return initialAccessToken;
75
- });
76
- const [refreshToken, setRefreshToken] = useState(() => {
77
- if (initialRefreshToken && typeof initialRefreshToken === 'string' && initialRefreshToken.trim() !== '') {
78
- if (typeof window !== 'undefined') {
79
- setRefreshTokenCookie(initialRefreshToken);
80
- }
81
- }
82
- return initialRefreshToken;
83
- });
84
-
85
- // Terminal "session expired" flag. Set by utils' refresh routines (via the
86
- // module listener registered below) when the refresh token is dead; reset when
87
- // a new refresh token appears (re-auth) so the breaker and the screen recover
88
- // together. Drives the shared session-expired screen and gates all fetching.
89
- const [sessionExpired, setSessionExpired] = useState(false);
90
- const markSessionExpired = useCallback(() => setSessionExpired(true), []);
91
-
92
- // Bridge the module-level refresh routines to React state. utils calls the
93
- // registered listener on terminal failure; this is the same single-instance
94
- // singleton model as the OTP refresh circuit breaker.
95
- useEffect(() => {
96
- setSessionExpiredListener(markSessionExpired);
97
- return () => setSessionExpiredListener(null);
98
- }, [markSessionExpired]);
99
-
100
- // Re-sync when props change (for token refresh scenarios)
101
- useEffect(() => {
102
- if (initialAccessToken && typeof initialAccessToken === 'string' && initialAccessToken.trim() !== '') {
103
- setAccessToken(initialAccessToken);
104
- if (typeof window !== 'undefined') {
105
- sessionStorage.setItem('access_token', initialAccessToken);
106
- syncJwtDataToSessionStorage(initialAccessToken);
107
- }
108
- }
109
- }, [initialAccessToken]);
110
-
111
- useEffect(() => {
112
- if (initialRefreshToken && typeof initialRefreshToken === 'string' && initialRefreshToken.trim() !== '') {
113
- setRefreshToken(initialRefreshToken);
114
- // A fresh refresh token means the user re-authenticated — clear the
115
- // terminal state (the breaker auto-re-arms on the next ensureValidToken).
116
- setSessionExpired(false);
117
- if (typeof window !== 'undefined') {
118
- setRefreshTokenCookie(initialRefreshToken);
119
- }
120
- }
121
- }, [initialRefreshToken]);
122
-
123
- // Internal method to update tokens after refresh
124
- const updateTokens = useCallback((newAccessToken: string, newRefreshToken?: string) => {
125
- setAccessToken(newAccessToken);
126
- if (newRefreshToken) {
127
- setRefreshToken(newRefreshToken);
128
- }
129
- // A successful refresh clears any prior terminal state.
130
- setSessionExpired(false);
131
- // Also update storage
132
- if (typeof window !== 'undefined') {
133
- sessionStorage.setItem('access_token', newAccessToken);
134
- // Extract and store org/auth data from JWT
135
- syncJwtDataToSessionStorage(newAccessToken);
136
- if (newRefreshToken) {
137
- setRefreshTokenCookie(newRefreshToken);
138
- }
139
- }
140
- }, []);
141
-
142
- // Memoize context value to prevent unnecessary re-renders
143
- const value: AuthContextValue = useMemo(() => ({
144
- accessToken,
145
- refreshToken,
146
- onError,
147
- updateTokens,
148
- sessionExpired,
149
- }), [accessToken, refreshToken, onError, updateTokens, sessionExpired]);
150
-
151
- return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
152
- };
153
-
154
- export const useAuth = (): AuthContextValue => {
155
- const context = useContext(AuthContext);
156
- if (!context) {
157
- throw new Error('useAuth must be used within an AuthProvider');
158
- }
159
- return context;
160
- };
@@ -1,47 +0,0 @@
1
- import { createContext, useContext, useMemo, type ReactNode } from 'react';
2
- import { createConsentClient } from '../api/client';
3
- import type { BaseUrlContextValue } from './types';
4
-
5
- export type { BaseUrlContextValue } from './types';
6
-
7
- export const BaseUrlContext = createContext<BaseUrlContextValue | null>(null);
8
-
9
- export const BaseUrlProvider = ({
10
- children,
11
- baseUrl,
12
- ledgerBaseUrl,
13
- }: {
14
- children: ReactNode;
15
- baseUrl: string; // Consent server base URL
16
- ledgerBaseUrl?: string; // Go ledger base URL — serves user-consents
17
- }) => {
18
- const consentClient = useMemo(
19
- () => createConsentClient(baseUrl, ledgerBaseUrl),
20
- [baseUrl, ledgerBaseUrl]
21
- );
22
-
23
- const value: BaseUrlContextValue = useMemo(
24
- () => ({
25
- baseUrl,
26
- ledgerBaseUrl,
27
- consentClient,
28
- }),
29
- [baseUrl, ledgerBaseUrl, consentClient]
30
- );
31
-
32
- return (
33
- <BaseUrlContext.Provider value={value}>
34
- {children}
35
- </BaseUrlContext.Provider>
36
- );
37
- };
38
-
39
- export const useBaseUrl = () => {
40
- const context = useContext(BaseUrlContext);
41
- if (!context) {
42
- throw new Error(
43
- 'useBaseUrl must be used within a BaseUrlProvider'
44
- );
45
- }
46
- return context;
47
- };
@@ -1,52 +0,0 @@
1
- import { createContext, useContext, useEffect, useState, type ReactNode } from 'react';
2
- import { fetchOrgBranding } from '../api/orgBranding';
3
- import { applyBrandingTheme, clearBrandingTheme } from '../styles/applyBrandingTheme';
4
- import type { OrgBrandingDetail } from '../lib/types';
5
-
6
- type BrandingContextValue = { branding: OrgBrandingDetail | null };
7
-
8
- const BrandingContext = createContext<BrandingContextValue | null>(null);
9
-
10
- export const BrandingProvider = ({
11
- children,
12
- slug,
13
- baseUrl,
14
- }: {
15
- children: ReactNode;
16
- slug: string;
17
- baseUrl: string;
18
- }) => {
19
- const [branding, setBranding] = useState<OrgBrandingDetail | null>(null);
20
-
21
- useEffect(() => {
22
- if (!slug) return;
23
- let cancelled = false;
24
- fetchOrgBranding(slug, baseUrl)
25
- .then((data) => {
26
- if (!cancelled) setBranding(data);
27
- })
28
- .catch((error) => {
29
- console.warn('[RedactoPrivacyCenter] org branding fetch failed:', error);
30
- });
31
- return () => {
32
- cancelled = true;
33
- };
34
- }, [slug, baseUrl]);
35
-
36
- useEffect(() => {
37
- if (!branding) return;
38
- applyBrandingTheme(branding.theme);
39
- return clearBrandingTheme;
40
- }, [branding]);
41
-
42
- return (
43
- <BrandingContext.Provider value={{ branding }}>
44
- {children}
45
- </BrandingContext.Provider>
46
- );
47
- };
48
-
49
- export const useBranding = (): OrgBrandingDetail | null => {
50
- const ctx = useContext(BrandingContext);
51
- return ctx?.branding ?? null;
52
- };
@@ -1,92 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
- import { render, screen, waitFor, cleanup } from '@testing-library/react';
3
- import {
4
- DataAvailabilityProvider,
5
- useDataAvailability,
6
- } from './DataAvailabilityContext';
7
-
8
- /**
9
- * Regression: when the session is terminally expired, the DataAvailabilityProvider
10
- * must NOT fire any data fetch on mount — it goes straight to the 'session-expired'
11
- * status so the shell renders the terminal screen instead of (fail-open) content.
12
- */
13
-
14
- // Mutable auth state shared with the hoisted mock so each test can flip it.
15
- const auth = vi.hoisted(() => ({
16
- current: {
17
- accessToken: 'stale-access-token',
18
- refreshToken: 'dead-refresh-token',
19
- onError: () => false,
20
- updateTokens: () => {},
21
- sessionExpired: true,
22
- },
23
- }));
24
-
25
- vi.mock('../lib/api', () => ({
26
- fetchUserConsents: vi.fn(() => Promise.resolve(null)),
27
- fetchActivities: vi.fn(() => Promise.resolve(null)),
28
- fetchCaseHistory: vi.fn(() => Promise.resolve(null)),
29
- }));
30
-
31
- vi.mock('./AuthContext', () => ({ useAuth: () => auth.current }));
32
- vi.mock('./OrganizationContext', () => ({
33
- useOrganization: () => ({
34
- organization: { uuid: 'org-uuid', workspaces: [{ uuid: 'ws-uuid' }] },
35
- }),
36
- }));
37
- vi.mock('./BaseUrlContext', () => ({ useBaseUrl: () => ({ consentClient: {} }) }));
38
- vi.mock('../lib/useCurrentLanguage', () => ({
39
- useCurrentLanguage: () => ({ langParam: 'en' }),
40
- }));
41
-
42
- import { fetchUserConsents, fetchActivities, fetchCaseHistory } from '../lib/api';
43
-
44
- function StatusProbe() {
45
- const { status } = useDataAvailability();
46
- return <div data-testid="status">{status}</div>;
47
- }
48
-
49
- describe('DataAvailabilityProvider — session-expired gate', () => {
50
- beforeEach(() => {
51
- vi.clearAllMocks();
52
- sessionStorage.clear();
53
- sessionStorage.setItem('email', 'user@example.com');
54
- auth.current = {
55
- accessToken: 'stale-access-token',
56
- refreshToken: 'dead-refresh-token',
57
- onError: () => false,
58
- updateTokens: () => {},
59
- sessionExpired: true,
60
- };
61
- });
62
-
63
- afterEach(() => cleanup());
64
-
65
- it('does not fetch and reports session-expired when the session is expired', () => {
66
- auth.current.sessionExpired = true;
67
-
68
- render(
69
- <DataAvailabilityProvider>
70
- <StatusProbe />
71
- </DataAvailabilityProvider>,
72
- );
73
-
74
- expect(screen.getByTestId('status').textContent).toBe('session-expired');
75
- expect(fetchUserConsents).not.toHaveBeenCalled();
76
- expect(fetchActivities).not.toHaveBeenCalled();
77
- expect(fetchCaseHistory).not.toHaveBeenCalled();
78
- });
79
-
80
- it('does fetch when the session is NOT expired (gate is meaningful)', async () => {
81
- auth.current.sessionExpired = false;
82
-
83
- render(
84
- <DataAvailabilityProvider>
85
- <StatusProbe />
86
- </DataAvailabilityProvider>,
87
- );
88
-
89
- await waitFor(() => expect(fetchUserConsents).toHaveBeenCalled());
90
- expect(fetchActivities).toHaveBeenCalled();
91
- });
92
- });
@@ -1,181 +0,0 @@
1
- import {
2
- createContext,
3
- useCallback,
4
- useContext,
5
- useEffect,
6
- useMemo,
7
- useRef,
8
- useState,
9
- type ReactNode,
10
- } from 'react';
11
- import { fetchUserConsents, fetchActivities, fetchCaseHistory } from '../lib/api';
12
- import { useCurrentLanguage } from '../lib/useCurrentLanguage';
13
- import { useOrganization } from './OrganizationContext';
14
- import { useAuth } from './AuthContext';
15
- import { useBaseUrl } from './BaseUrlContext';
16
-
17
- export type DataAvailabilityStatus =
18
- | 'checking'
19
- | 'has-data'
20
- | 'empty'
21
- | 'session-expired';
22
-
23
- type DataAvailabilityContextValue = {
24
- status: DataAvailabilityStatus;
25
- };
26
-
27
- const DataAvailabilityContext = createContext<DataAvailabilityContextValue | null>(null);
28
-
29
- /**
30
- * Determines whether the authenticated user has ANY data in the Privacy Center
31
- * (consents, data-request cases, or activity). When all three are empty we
32
- * surface a dedicated empty state instead of dropping the user into a shell
33
- * full of empty tables.
34
- *
35
- * Fail-open by design: the underlying fetchers return `null` on non-auth
36
- * errors (and may reject if a post-refresh retry throws). A `null`/rejected
37
- * signal is treated as "has data" so a transient or auth error never wrongly
38
- * locks a user out — the empty state shows ONLY when all three signals
39
- * conclusively resolve to empty.
40
- */
41
- export const DataAvailabilityProvider = ({ children }: { children: ReactNode }) => {
42
- const { organization } = useOrganization();
43
- const { accessToken, refreshToken, onError, updateTokens, sessionExpired } = useAuth();
44
- const { consentClient } = useBaseUrl();
45
- const { langParam } = useCurrentLanguage();
46
-
47
- const organizationId = organization?.uuid;
48
- const workspaceId = organization?.workspaces[0]?.uuid;
49
-
50
- // Memoized to keep the fetch identity stable across renders (mirrors the
51
- // canonical pattern in ActivitiesList / AuthContext).
52
- const authContext = useMemo(
53
- () => ({ accessToken, refreshToken, onError, updateTokens }),
54
- [accessToken, refreshToken, onError, updateTokens],
55
- );
56
-
57
- const [status, setStatus] = useState<DataAvailabilityStatus>('checking');
58
-
59
- // Monotonic run id guards against a stale in-flight check (org/token changed)
60
- // overwriting a newer one; mountedRef guards against setState after unmount.
61
- const runIdRef = useRef(0);
62
- const mountedRef = useRef(true);
63
- useEffect(() => {
64
- mountedRef.current = true;
65
- return () => {
66
- mountedRef.current = false;
67
- };
68
- }, []);
69
-
70
- const runCheck = useCallback(async () => {
71
- if (!organizationId || !workspaceId) return;
72
-
73
- const runId = ++runIdRef.current;
74
- setStatus('checking');
75
-
76
- // Cases require the user's email (same source the request Form reads).
77
- const contact =
78
- typeof window !== 'undefined' ? sessionStorage.getItem('email') : null;
79
-
80
- // Each signal resolves to a boolean "is empty". A `null` result (the
81
- // fetchers' non-auth error path) or a rejection (rare post-refresh retry
82
- // throw) resolves to `false` so the signal counts as "has data" — the
83
- // empty state shows ONLY when all three conclusively resolve to empty.
84
- const consentsEmptyP: Promise<boolean> = fetchUserConsents({
85
- organizationId,
86
- workspaceId,
87
- limit: 1,
88
- nominatedLimit: 1,
89
- language: langParam,
90
- authContext,
91
- consentClient,
92
- })
93
- .then(
94
- (v) =>
95
- !!v &&
96
- v.status_summary?.total_purposes === 0 &&
97
- (v.direct?.length ?? 0) === 0 &&
98
- (v.nominated?.length ?? 0) === 0 &&
99
- (v.nominators?.length ?? 0) === 0,
100
- )
101
- .catch(() => false);
102
-
103
- // No contact => we can't check cases, so treat as empty and rely on the
104
- // other two signals' fail-open. With a contact, a null/rejected result
105
- // fails open (not empty).
106
- const casesEmptyP: Promise<boolean> = contact
107
- ? fetchCaseHistory(
108
- organizationId,
109
- workspaceId,
110
- contact,
111
- 0,
112
- 1,
113
- authContext,
114
- consentClient,
115
- langParam,
116
- )
117
- .then((v) => !!v && (v.data?.length ?? 0) === 0)
118
- .catch(() => false)
119
- : Promise.resolve(true);
120
-
121
- const activitiesEmptyP: Promise<boolean> = fetchActivities(
122
- organizationId,
123
- workspaceId,
124
- 0,
125
- 1,
126
- authContext,
127
- consentClient,
128
- langParam,
129
- )
130
- .then((v) => !!v && (v.pagination?.total_count ?? 0) === 0)
131
- .catch(() => false);
132
-
133
- const [consentsEmpty, casesEmpty, activitiesEmpty] = await Promise.all([
134
- consentsEmptyP,
135
- casesEmptyP,
136
- activitiesEmptyP,
137
- ]);
138
-
139
- // Ignore if a newer check superseded this one or we unmounted.
140
- if (!mountedRef.current || runId !== runIdRef.current) return;
141
-
142
- setStatus(
143
- consentsEmpty && casesEmpty && activitiesEmpty ? 'empty' : 'has-data',
144
- );
145
- }, [organizationId, workspaceId, authContext, consentClient, langParam]);
146
-
147
- useEffect(() => {
148
- // Terminal session: never fetch. Bump the run id so any in-flight runCheck
149
- // resolves into a no-op (its fail-open path would otherwise flip the status
150
- // back to 'has-data' and remount the content), then show the expired screen.
151
- if (sessionExpired) {
152
- runIdRef.current += 1;
153
- setStatus('session-expired');
154
- return;
155
- }
156
- if (organizationId && workspaceId && accessToken) {
157
- void runCheck();
158
- }
159
- }, [organizationId, workspaceId, accessToken, runCheck, sessionExpired]);
160
-
161
- const value = useMemo<DataAvailabilityContextValue>(
162
- () => ({ status }),
163
- [status],
164
- );
165
-
166
- return (
167
- <DataAvailabilityContext.Provider value={value}>
168
- {children}
169
- </DataAvailabilityContext.Provider>
170
- );
171
- };
172
-
173
- export const useDataAvailability = (): DataAvailabilityContextValue => {
174
- const ctx = useContext(DataAvailabilityContext);
175
- if (!ctx) {
176
- throw new Error(
177
- 'useDataAvailability must be used within a DataAvailabilityProvider',
178
- );
179
- }
180
- return ctx;
181
- };
@@ -1,11 +0,0 @@
1
- import { createContext } from 'react';
2
-
3
- type LocaleContextType = {
4
- locale: string;
5
- setLocale: (locale: string) => void;
6
- };
7
-
8
- export const LocaleContext = createContext<LocaleContextType>({
9
- locale: 'en',
10
- setLocale: () => {},
11
- });
@@ -1,96 +0,0 @@
1
- import { createContext, useContext, useState, useCallback, type ReactNode } from 'react';
2
- import type { CaseRequest } from '../lib/types';
3
-
4
- export type InternalPage = 'consent-manager' | 'form' | 'activity' | 'case-details' | 'notifications' | 'receipts';
5
-
6
- const NAV_STORAGE_KEY = 'pc_current_page';
7
- const CASE_UUID_STORAGE_KEY = 'pc_selected_case_uuid';
8
-
9
- const VALID_PAGES: ReadonlySet<string> = new Set<InternalPage>([
10
- 'consent-manager', 'form', 'activity', 'case-details', 'notifications', 'receipts',
11
- ]);
12
-
13
- function getStoredPage(fallback: InternalPage): InternalPage {
14
- if (typeof window === 'undefined') return fallback;
15
- try {
16
- const stored = sessionStorage.getItem(NAV_STORAGE_KEY);
17
- if (stored && VALID_PAGES.has(stored)) {
18
- return stored as InternalPage;
19
- }
20
- } catch {
21
- // sessionStorage unavailable
22
- }
23
- return fallback;
24
- }
25
-
26
- function getStoredCaseUuid(): string | null {
27
- if (typeof window === 'undefined') return null;
28
- try {
29
- return sessionStorage.getItem(CASE_UUID_STORAGE_KEY);
30
- } catch {
31
- return null;
32
- }
33
- }
34
-
35
- interface NavigationContextType {
36
- currentPage: InternalPage;
37
- navigateTo: (page: InternalPage) => void;
38
- selectedCase: CaseRequest | null;
39
- setSelectedCase: (c: CaseRequest | null) => void;
40
- pendingCaseUuid: string | null;
41
- }
42
-
43
- const NavigationContext = createContext<NavigationContextType | null>(null);
44
-
45
- export const NavigationProvider = ({
46
- children,
47
- initialPage = 'consent-manager'
48
- }: {
49
- children: ReactNode;
50
- initialPage?: InternalPage;
51
- }) => {
52
- const [currentPage, setCurrentPage] = useState<InternalPage>(
53
- () => getStoredPage(initialPage)
54
- );
55
- const [selectedCase, setSelectedCaseState] = useState<CaseRequest | null>(null);
56
- const [pendingCaseUuid] = useState<string | null>(() => getStoredCaseUuid());
57
-
58
- const setSelectedCase = useCallback((c: CaseRequest | null) => {
59
- setSelectedCaseState(c);
60
- try {
61
- if (c?.uuid) {
62
- sessionStorage.setItem(CASE_UUID_STORAGE_KEY, c.uuid);
63
- } else {
64
- sessionStorage.removeItem(CASE_UUID_STORAGE_KEY);
65
- }
66
- } catch {
67
- // sessionStorage unavailable
68
- }
69
- }, []);
70
-
71
- const navigateTo = useCallback((page: InternalPage) => {
72
- setCurrentPage(page);
73
- if (page !== 'case-details') {
74
- setSelectedCaseState(null);
75
- }
76
- try {
77
- sessionStorage.setItem(NAV_STORAGE_KEY, page);
78
- } catch {
79
- // sessionStorage unavailable
80
- }
81
- }, []);
82
-
83
- return (
84
- <NavigationContext.Provider value={{ currentPage, navigateTo, selectedCase, setSelectedCase, pendingCaseUuid }}>
85
- {children}
86
- </NavigationContext.Provider>
87
- );
88
- };
89
-
90
- export const useInternalNavigation = () => {
91
- const context = useContext(NavigationContext);
92
- if (!context) {
93
- throw new Error('useInternalNavigation must be used within a NavigationProvider');
94
- }
95
- return context;
96
- };
@@ -1,30 +0,0 @@
1
- import { createContext, useContext, type ReactNode } from 'react';
2
- import type { OrganizationDetail } from '../lib/types';
3
-
4
- export const OrganizationContext = createContext<{
5
- organization: OrganizationDetail | null;
6
- } | null>(null);
7
-
8
- export const OrganizationProvider = ({
9
- children,
10
- organization,
11
- }: {
12
- children: ReactNode;
13
- organization: OrganizationDetail | null;
14
- }) => {
15
- return (
16
- <OrganizationContext.Provider value={{ organization }}>
17
- {children}
18
- </OrganizationContext.Provider>
19
- );
20
- };
21
-
22
- export const useOrganization = () => {
23
- const context = useContext(OrganizationContext);
24
- if (!context) {
25
- throw new Error(
26
- 'useOrganization must be used within a OrganizationProvider'
27
- );
28
- }
29
- return context;
30
- };