@redacto.io/consent-sdk-react 10.0.0-beta.11 → 10.0.0-beta.12

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 (259) hide show
  1. package/NOTICE.md +17 -0
  2. package/README.md +67 -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 +613 -249
  11. package/dist/index.mjs +235 -85
  12. package/dist/montserrat.generated-NBTECYRW.mjs +22 -0
  13. package/dist/types-6Aj7faxL.d.mts +57 -0
  14. package/dist/types-6Aj7faxL.d.ts +57 -0
  15. package/package.json +10 -1
  16. package/.turbo/turbo-build.log +0 -22
  17. package/.turbo/turbo-test.log +0 -203
  18. package/.turbo/turbo-verify-pack.log +0 -6
  19. package/CHANGELOG.md +0 -383
  20. package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.test.tsx +0 -934
  21. package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.tsx +0 -2160
  22. package/src/RedactoNoticeAssisted/api/index.ts +0 -275
  23. package/src/RedactoNoticeAssisted/api/types.ts +0 -182
  24. package/src/RedactoNoticeAssisted/assets/redacto-logo.png +0 -0
  25. package/src/RedactoNoticeAssisted/constants.ts +0 -51
  26. package/src/RedactoNoticeAssisted/i18n.ts +0 -1408
  27. package/src/RedactoNoticeAssisted/index.ts +0 -1
  28. package/src/RedactoNoticeAssisted/injectStyles.ts +0 -251
  29. package/src/RedactoNoticeAssisted/styles.ts +0 -730
  30. package/src/RedactoNoticeAssisted/types.ts +0 -26
  31. package/src/RedactoNoticeAssisted/useMediaQuery.ts +0 -36
  32. package/src/RedactoNoticeConsent/RedactoNoticeConsent.test.tsx +0 -1186
  33. package/src/RedactoNoticeConsent/RedactoNoticeConsent.tsx +0 -4299
  34. package/src/RedactoNoticeConsent/api/index.ts +0 -486
  35. package/src/RedactoNoticeConsent/api/sandbox.ts +0 -150
  36. package/src/RedactoNoticeConsent/api/types.ts +0 -505
  37. package/src/RedactoNoticeConsent/assets/redacto-logo.png +0 -0
  38. package/src/RedactoNoticeConsent/components/DigiLockerCallback.tsx +0 -602
  39. package/src/RedactoNoticeConsent/components/index.ts +0 -7
  40. package/src/RedactoNoticeConsent/constants.ts +0 -20
  41. package/src/RedactoNoticeConsent/index.ts +0 -1
  42. package/src/RedactoNoticeConsent/injectStyles.ts +0 -151
  43. package/src/RedactoNoticeConsent/language-codes.ts +0 -95
  44. package/src/RedactoNoticeConsent/services/storage.ts +0 -122
  45. package/src/RedactoNoticeConsent/styles.ts +0 -409
  46. package/src/RedactoNoticeConsent/types.ts +0 -80
  47. package/src/RedactoNoticeConsent/useMediaQuery.ts +0 -36
  48. package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.test.tsx +0 -369
  49. package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.tsx +0 -709
  50. package/src/RedactoNoticeConsentInline/api/index.ts +0 -115
  51. package/src/RedactoNoticeConsentInline/api/notice-read-routing.test.ts +0 -72
  52. package/src/RedactoNoticeConsentInline/api/types.ts +0 -185
  53. package/src/RedactoNoticeConsentInline/assets/redacto-logo.png +0 -0
  54. package/src/RedactoNoticeConsentInline/index.ts +0 -1
  55. package/src/RedactoNoticeConsentInline/injectStyles.ts +0 -40
  56. package/src/RedactoNoticeConsentInline/styles.ts +0 -397
  57. package/src/RedactoNoticeConsentInline/types.ts +0 -51
  58. package/src/RedactoNoticeConsentInline/useMediaQuery.ts +0 -36
  59. package/src/RedactoPrivacyCenter/NotificationsPage.tsx +0 -182
  60. package/src/RedactoPrivacyCenter/PrivacyCenterActivityPage.tsx +0 -19
  61. package/src/RedactoPrivacyCenter/PrivacyCenterCaseDetailsPage.tsx +0 -156
  62. package/src/RedactoPrivacyCenter/PrivacyCenterConsentManagerPage.tsx +0 -17
  63. package/src/RedactoPrivacyCenter/PrivacyCenterFormPage.tsx +0 -79
  64. package/src/RedactoPrivacyCenter/PrivacyCenterHomePage.tsx +0 -36
  65. package/src/RedactoPrivacyCenter/PrivacyCenterLayout.tsx +0 -177
  66. package/src/RedactoPrivacyCenter/PrivacyCenterMyReceiptPage.tsx +0 -26
  67. package/src/RedactoPrivacyCenter/RedactoPrivacyCenter.tsx +0 -93
  68. package/src/RedactoPrivacyCenter/api/actions.ts +0 -682
  69. package/src/RedactoPrivacyCenter/api/client.ts +0 -1003
  70. package/src/RedactoPrivacyCenter/api/config.ts +0 -33
  71. package/src/RedactoPrivacyCenter/api/fetcher.ts +0 -275
  72. package/src/RedactoPrivacyCenter/api/orgBranding.ts +0 -16
  73. package/src/RedactoPrivacyCenter/api/upload.ts +0 -93
  74. package/src/RedactoPrivacyCenter/assets/character.svg +0 -31
  75. package/src/RedactoPrivacyCenter/assets/fileAttach.svg +0 -9
  76. package/src/RedactoPrivacyCenter/assets/greenTick.svg +0 -4
  77. package/src/RedactoPrivacyCenter/assets/mail.svg +0 -3
  78. package/src/RedactoPrivacyCenter/assets/poweredByRedacto.svg +0 -9
  79. package/src/RedactoPrivacyCenter/assets/sentImg.svg +0 -9
  80. package/src/RedactoPrivacyCenter/assets/uploadFileIcon.svg +0 -9
  81. package/src/RedactoPrivacyCenter/components/ActivitiesList.tsx +0 -252
  82. package/src/RedactoPrivacyCenter/components/ActivityTimeline.tsx +0 -239
  83. package/src/RedactoPrivacyCenter/components/AppShell/AppShell.tsx +0 -268
  84. package/src/RedactoPrivacyCenter/components/AppShell/MobileNavDrawer.tsx +0 -218
  85. package/src/RedactoPrivacyCenter/components/AppShell/NavItem.tsx +0 -205
  86. package/src/RedactoPrivacyCenter/components/AppShell/PageHeader.tsx +0 -107
  87. package/src/RedactoPrivacyCenter/components/AppShell/SidebarNav.tsx +0 -100
  88. package/src/RedactoPrivacyCenter/components/AppShell/TopAppBar.tsx +0 -339
  89. package/src/RedactoPrivacyCenter/components/AppShell/UserMenu.tsx +0 -245
  90. package/src/RedactoPrivacyCenter/components/AppShell/hooks/useIsTruncated.ts +0 -28
  91. package/src/RedactoPrivacyCenter/components/AppShell/hooks/useKeyboardShortcut.ts +0 -40
  92. package/src/RedactoPrivacyCenter/components/AppShell/hooks/useSidebarState.ts +0 -62
  93. package/src/RedactoPrivacyCenter/components/AppShell/usePrivacyCenterExitAction.ts +0 -36
  94. package/src/RedactoPrivacyCenter/components/CaseDetails/AttachmentCard.tsx +0 -38
  95. package/src/RedactoPrivacyCenter/components/CaseDetails/ChatBubble.tsx +0 -31
  96. package/src/RedactoPrivacyCenter/components/CaseDetails/DocumentRequestCard.tsx +0 -79
  97. package/src/RedactoPrivacyCenter/components/CaseDetails/FinalizedTooltipWrapper.tsx +0 -25
  98. package/src/RedactoPrivacyCenter/components/CaseDetails/MessageComposer.tsx +0 -96
  99. package/src/RedactoPrivacyCenter/components/CaseDetails/MessageItem.tsx +0 -97
  100. package/src/RedactoPrivacyCenter/components/CaseDetails/MessagesTab.tsx +0 -156
  101. package/src/RedactoPrivacyCenter/components/CaseDetails/RequestDetailsTab.tsx +0 -171
  102. package/src/RedactoPrivacyCenter/components/CaseDetails/StatusEvent.tsx +0 -23
  103. package/src/RedactoPrivacyCenter/components/CaseDetails/useFileUpload.ts +0 -116
  104. package/src/RedactoPrivacyCenter/components/CaseDetails/useMessagePolling.ts +0 -43
  105. package/src/RedactoPrivacyCenter/components/CaseDetails/utils.ts +0 -71
  106. package/src/RedactoPrivacyCenter/components/CaseDetailsModal.tsx +0 -469
  107. package/src/RedactoPrivacyCenter/components/CaseHistory.tsx +0 -426
  108. package/src/RedactoPrivacyCenter/components/ConsentManager.tsx +0 -1199
  109. package/src/RedactoPrivacyCenter/components/ConsentManagerCells.tsx +0 -201
  110. package/src/RedactoPrivacyCenter/components/ConsentManagerColumns.tsx +0 -138
  111. package/src/RedactoPrivacyCenter/components/ConsentManagerConstants.ts +0 -7
  112. package/src/RedactoPrivacyCenter/components/ConsentManagerExpandedRow.tsx +0 -179
  113. package/src/RedactoPrivacyCenter/components/ConsentManagerGroupedColumns.tsx +0 -318
  114. package/src/RedactoPrivacyCenter/components/ConsentManagerProductCards.tsx +0 -333
  115. package/src/RedactoPrivacyCenter/components/ConsentManagerPurposeCards.tsx +0 -102
  116. package/src/RedactoPrivacyCenter/components/ConsentManagerTableSkeleton.tsx +0 -159
  117. package/src/RedactoPrivacyCenter/components/DataRequest/CorrectionDataSection.tsx +0 -189
  118. package/src/RedactoPrivacyCenter/components/DataRequest/GrievanceDataSection.tsx +0 -118
  119. package/src/RedactoPrivacyCenter/components/DataRequest/NominationDataSection.tsx +0 -66
  120. package/src/RedactoPrivacyCenter/components/DataRequest/ProductSelectionSection.tsx +0 -222
  121. package/src/RedactoPrivacyCenter/components/DataRequest/PurposeSelectionSection.tsx +0 -331
  122. package/src/RedactoPrivacyCenter/components/Form.tsx +0 -1821
  123. package/src/RedactoPrivacyCenter/components/GrievanceTable.tsx +0 -174
  124. package/src/RedactoPrivacyCenter/components/GrievanceTablePagination.tsx +0 -337
  125. package/src/RedactoPrivacyCenter/components/ModifyConsentModal.tsx +0 -334
  126. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationBell.tsx +0 -173
  127. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationCTAButton.tsx +0 -18
  128. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationDropdown.tsx +0 -54
  129. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationDropdownItem.tsx +0 -57
  130. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationIcon.tsx +0 -19
  131. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationListPanel.tsx +0 -92
  132. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationRefreshButton.tsx +0 -20
  133. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationRow.tsx +0 -58
  134. package/src/RedactoPrivacyCenter/components/NotificationHub/StatCard.tsx +0 -10
  135. package/src/RedactoPrivacyCenter/components/NotificationHub/useNotificationActions.ts +0 -112
  136. package/src/RedactoPrivacyCenter/components/NotificationHub/utils.ts +0 -27
  137. package/src/RedactoPrivacyCenter/components/Pagination.tsx +0 -140
  138. package/src/RedactoPrivacyCenter/components/PrivacyCenterEmptyState.tsx +0 -76
  139. package/src/RedactoPrivacyCenter/components/PrivacyCenterSessionExpired.tsx +0 -97
  140. package/src/RedactoPrivacyCenter/components/ReceiptsList.tsx +0 -454
  141. package/src/RedactoPrivacyCenter/components/RequestSubmit.tsx +0 -270
  142. package/src/RedactoPrivacyCenter/components/SelectUser.tsx +0 -95
  143. package/src/RedactoPrivacyCenter/components/SelectUserGate.tsx +0 -195
  144. package/src/RedactoPrivacyCenter/components/SideMenuBarPC/constants.tsx +0 -25
  145. package/src/RedactoPrivacyCenter/components/SideMenuBarPC/types.ts +0 -21
  146. package/src/RedactoPrivacyCenter/components/caseHistoryColumns.tsx +0 -159
  147. package/src/RedactoPrivacyCenter/components/constant.ts +0 -52
  148. package/src/RedactoPrivacyCenter/components/groupHelpers.ts +0 -155
  149. package/src/RedactoPrivacyCenter/components/receiptColumns.tsx +0 -203
  150. package/src/RedactoPrivacyCenter/components/types.ts +0 -123
  151. package/src/RedactoPrivacyCenter/components/utils.tsx +0 -10
  152. package/src/RedactoPrivacyCenter/config/routes.ts +0 -9
  153. package/src/RedactoPrivacyCenter/config/table.ts +0 -25
  154. package/src/RedactoPrivacyCenter/context/AuthContext.tsx +0 -252
  155. package/src/RedactoPrivacyCenter/context/BaseUrlContext.tsx +0 -47
  156. package/src/RedactoPrivacyCenter/context/BrandingContext.tsx +0 -52
  157. package/src/RedactoPrivacyCenter/context/DataAvailabilityContext.session-expired.test.tsx +0 -92
  158. package/src/RedactoPrivacyCenter/context/DataAvailabilityContext.tsx +0 -181
  159. package/src/RedactoPrivacyCenter/context/LocaleContext.tsx +0 -11
  160. package/src/RedactoPrivacyCenter/context/NavigationContext.tsx +0 -96
  161. package/src/RedactoPrivacyCenter/context/OrganizationContext.tsx +0 -30
  162. package/src/RedactoPrivacyCenter/context/PageChromeContext.tsx +0 -80
  163. package/src/RedactoPrivacyCenter/context/ProfileSwitchContext.tsx +0 -15
  164. package/src/RedactoPrivacyCenter/context/types.ts +0 -57
  165. package/src/RedactoPrivacyCenter/lib/api.ts +0 -759
  166. package/src/RedactoPrivacyCenter/lib/consent-manager/utils.tsx +0 -67
  167. package/src/RedactoPrivacyCenter/lib/constants.ts +0 -283
  168. package/src/RedactoPrivacyCenter/lib/i18n.ts +0 -81
  169. package/src/RedactoPrivacyCenter/lib/locales.ts +0 -102
  170. package/src/RedactoPrivacyCenter/lib/queries.ts +0 -141
  171. package/src/RedactoPrivacyCenter/lib/sandbox.ts +0 -104
  172. package/src/RedactoPrivacyCenter/lib/types.ts +0 -892
  173. package/src/RedactoPrivacyCenter/lib/useCurrentLanguage.ts +0 -37
  174. package/src/RedactoPrivacyCenter/lib/utils.refresh-circuit.test.ts +0 -127
  175. package/src/RedactoPrivacyCenter/lib/utils.refresh-storage.test.ts +0 -85
  176. package/src/RedactoPrivacyCenter/lib/utils.session-expired.test.ts +0 -109
  177. package/src/RedactoPrivacyCenter/lib/utils.ts +0 -798
  178. package/src/RedactoPrivacyCenter/locales/as/translation.json +0 -340
  179. package/src/RedactoPrivacyCenter/locales/bn/translation.json +0 -340
  180. package/src/RedactoPrivacyCenter/locales/brx/translation.json +0 -340
  181. package/src/RedactoPrivacyCenter/locales/doi/translation.json +0 -340
  182. package/src/RedactoPrivacyCenter/locales/en/translation.json +0 -355
  183. package/src/RedactoPrivacyCenter/locales/gom/translation.json +0 -340
  184. package/src/RedactoPrivacyCenter/locales/gu/translation.json +0 -340
  185. package/src/RedactoPrivacyCenter/locales/hi/translation.json +0 -343
  186. package/src/RedactoPrivacyCenter/locales/kn/translation.json +0 -340
  187. package/src/RedactoPrivacyCenter/locales/ks/translation.json +0 -340
  188. package/src/RedactoPrivacyCenter/locales/mai/translation.json +0 -340
  189. package/src/RedactoPrivacyCenter/locales/ml/translation.json +0 -340
  190. package/src/RedactoPrivacyCenter/locales/mni-Mtei/translation.json +0 -340
  191. package/src/RedactoPrivacyCenter/locales/mr/translation.json +0 -340
  192. package/src/RedactoPrivacyCenter/locales/ne/translation.json +0 -340
  193. package/src/RedactoPrivacyCenter/locales/or/translation.json +0 -340
  194. package/src/RedactoPrivacyCenter/locales/pa/translation.json +0 -340
  195. package/src/RedactoPrivacyCenter/locales/sa/translation.json +0 -340
  196. package/src/RedactoPrivacyCenter/locales/sat/translation.json +0 -340
  197. package/src/RedactoPrivacyCenter/locales/sd/translation.json +0 -340
  198. package/src/RedactoPrivacyCenter/locales/ta/translation.json +0 -340
  199. package/src/RedactoPrivacyCenter/locales/te/translation.json +0 -340
  200. package/src/RedactoPrivacyCenter/locales/ur/translation.json +0 -340
  201. package/src/RedactoPrivacyCenter/styles/applyBrandingTheme.ts +0 -66
  202. package/src/RedactoPrivacyCenter/styles/base.css +0 -117
  203. package/src/RedactoPrivacyCenter/styles/injectStyles.ts +0 -3108
  204. package/src/RedactoPrivacyCenter/styles/pcStyles.ts +0 -831
  205. package/src/RedactoPrivacyCenter/styles/responsive.ts +0 -138
  206. package/src/RedactoPrivacyCenter/styles/variables.css +0 -96
  207. package/src/RedactoPrivacyCenter/table/AdvancedTable.tsx +0 -387
  208. package/src/RedactoPrivacyCenter/table/AdvancedTablePagination.tsx +0 -468
  209. package/src/RedactoPrivacyCenter/table/index.ts +0 -2
  210. package/src/RedactoPrivacyCenter/types/images.d.ts +0 -29
  211. package/src/RedactoPrivacyCenter/ui/Footer.tsx +0 -69
  212. package/src/RedactoPrivacyCenter/ui/FormBlockWrapper.tsx +0 -54
  213. package/src/RedactoPrivacyCenter/ui/PCAccordion.tsx +0 -93
  214. package/src/RedactoPrivacyCenter/ui/PCActionIcon.tsx +0 -47
  215. package/src/RedactoPrivacyCenter/ui/PCAvatar.test.tsx +0 -83
  216. package/src/RedactoPrivacyCenter/ui/PCAvatar.tsx +0 -93
  217. package/src/RedactoPrivacyCenter/ui/PCBadge.tsx +0 -48
  218. package/src/RedactoPrivacyCenter/ui/PCButton.tsx +0 -77
  219. package/src/RedactoPrivacyCenter/ui/PCCheckbox.tsx +0 -55
  220. package/src/RedactoPrivacyCenter/ui/PCCollapse.tsx +0 -107
  221. package/src/RedactoPrivacyCenter/ui/PCEmpty.tsx +0 -35
  222. package/src/RedactoPrivacyCenter/ui/PCInput.tsx +0 -132
  223. package/src/RedactoPrivacyCenter/ui/PCLoader.tsx +0 -31
  224. package/src/RedactoPrivacyCenter/ui/PCModal.tsx +0 -106
  225. package/src/RedactoPrivacyCenter/ui/PCPopover.tsx +0 -206
  226. package/src/RedactoPrivacyCenter/ui/PCSelect.tsx +0 -433
  227. package/src/RedactoPrivacyCenter/ui/PCTable.tsx +0 -149
  228. package/src/RedactoPrivacyCenter/ui/PCText.tsx +0 -41
  229. package/src/RedactoPrivacyCenter/ui/PCTextarea.tsx +0 -43
  230. package/src/RedactoPrivacyCenter/ui/PCTitle.tsx +0 -37
  231. package/src/RedactoPrivacyCenter/ui/PCTooltip.tsx +0 -121
  232. package/src/RedactoPrivacyCenter/ui/SimpleBar.tsx +0 -25
  233. package/src/RedactoPrivacyCenter/ui/StatusBadge.tsx +0 -53
  234. package/src/RedactoPrivacyCenter/ui/index.ts +0 -18
  235. package/src/RedactoPrivacyCenter/utils/cn.ts +0 -28
  236. package/src/RedactoPrivacyCenter/utils/date.ts +0 -48
  237. package/src/RedactoPrivacyCenter/utils/status.ts +0 -111
  238. package/src/RedactoPrivacyCenter/utils/toast.ts +0 -130
  239. package/src/index.ts +0 -19
  240. package/src/privacy-center.ts +0 -113
  241. package/src/shared/api-errors.ts +0 -180
  242. package/src/shared/notice-consent-status.ts +0 -190
  243. package/src/shared/sandbox.ts +0 -6
  244. package/src/types/css.d.ts +0 -4
  245. package/src/types/images.d.ts +0 -19
  246. package/src/types/react-jsx.d.ts +0 -26
  247. package/tests/DataAvailabilityContext.test.tsx +0 -123
  248. package/tests/Form.test.tsx +0 -1424
  249. package/tests/ProductSelectionSection.test.tsx +0 -328
  250. package/tests/RequestSubmit.test.tsx +0 -135
  251. package/tests/RevokeWarningMessage.test.tsx +0 -151
  252. package/tests/consentClient.test.ts +0 -217
  253. package/tests/manageConsentServer.test.ts +0 -38
  254. package/tests/mocks.ts +0 -257
  255. package/tests/resolveContactFromJwt.test.ts +0 -44
  256. package/tests/setup.ts +0 -16
  257. package/tsconfig.json +0 -16
  258. package/tsup.config.ts +0 -31
  259. package/vitest.config.ts +0 -16
@@ -1,602 +0,0 @@
1
- /**
2
- * DigiLockerCallback Component
3
- *
4
- * Standalone component for handling DigiLocker redirect callbacks.
5
- * Clients should add this to their routing (e.g., /digilocker-callback page).
6
- *
7
- * Usage in Next.js:
8
- * ```tsx
9
- * // pages/digilocker-callback.tsx
10
- * import { DigiLockerCallback } from '@redacto.io/consent-sdk-react';
11
- *
12
- * export default function DigiLockerCallbackPage() {
13
- * return <DigiLockerCallback accessToken={"<token>"} />;
14
- * }
15
- * ```
16
- *
17
- * Usage in React Router:
18
- * ```tsx
19
- * <Route path="/digilocker-callback" element={<DigiLockerCallback accessToken={"<token>"} />} />
20
- * ```
21
- *
22
- * URL Parameters expected from redirect:
23
- * - session_token: The verification session token
24
- * - status: "verified" | "failed" | "expired"
25
- * - verification_reference: (if verified) Reference for consent submission
26
- * - error_code: (if failed) Error code like GUARDIAN_UNDER_18, SESSION_EXPIRED, etc.
27
- */
28
-
29
- import React, { useCallback, useEffect, useRef, useState } from "react";
30
- import { verifyGuardianStatus } from "../api";
31
- import type { DigiLockerCallbackProps, GuardianVerificationErrorCode } from "../api/types";
32
- import { injectCheckboxStyles } from "../injectStyles";
33
- import {
34
- clearConsentState,
35
- getConsentState,
36
- updateConsentState,
37
- } from "../services/storage";
38
-
39
- type CallbackStatus = "processing" | "success" | "error";
40
-
41
- export const DigiLockerCallback: React.FC<DigiLockerCallbackProps> = ({
42
- accessToken: propAccessToken,
43
- baseUrl,
44
- onSuccess,
45
- onError,
46
- }) => {
47
- const [status, setStatus] = useState<CallbackStatus>("processing");
48
- const [message, setMessage] = useState("Verifying your guardian...");
49
- const [errorDetail, setErrorDetail] = useState<string | null>(null);
50
- const retryTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
51
- const redirectTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
52
- const isMountedRef = useRef(true);
53
-
54
- const getErrorMessage = (errorCode?: GuardianVerificationErrorCode): string => {
55
- switch (errorCode) {
56
- case "GUARDIAN_UNDER_18":
57
- return "Guardian verification failed: The guardian must be 18 years or older.";
58
- case "SESSION_EXPIRED":
59
- return "Verification session has expired. Please restart the verification process.";
60
- case "TOKEN_FAILED":
61
- return "DigiLocker authentication failed. Please try again.";
62
- case "DIGILOCKER_AUTH_FAILED":
63
- return "DigiLocker authorization was cancelled or failed. Please try again.";
64
- case "NO_AUTH_CODE":
65
- return "Missing authorization code from DigiLocker. Please try again.";
66
- default:
67
- return "Verification failed. Please try again.";
68
- }
69
- };
70
-
71
- const redirectToOriginalPage = useCallback(
72
- (
73
- originalUrl: string,
74
- verificationResult: "verified" | "failed" | "expired",
75
- verificationReference?: string
76
- ) => {
77
- // Update persisted state with verification result
78
- updateConsentState({
79
- verificationResult,
80
- verificationReference,
81
- flowState: verificationResult === "verified" ? "consent-form" : "error",
82
- });
83
-
84
- // Redirect back to original page
85
- redirectTimeoutRef.current = setTimeout(() => {
86
- window.location.href = originalUrl;
87
- }, 1500);
88
- },
89
- []
90
- );
91
-
92
- const handleCallback = useCallback(async () => {
93
- try {
94
- // 1. Extract URL parameters (new format from backend)
95
- const params = new URLSearchParams(window.location.search);
96
- const sessionToken = params.get("session_token");
97
- const urlStatus = params.get("status") as "verified" | "failed" | "expired" | null;
98
- const verificationReference = params.get("verification_reference");
99
- const errorCode = params.get("error_code") as GuardianVerificationErrorCode | null;
100
-
101
- // 2. Retrieve persisted state (optional — popup mode may not have saved state)
102
- const persistedState = getConsentState();
103
-
104
- const originalUrl = persistedState?.originalUrl || "/";
105
- const storedBaseUrl = persistedState?.baseUrl;
106
- const storedSessionToken = persistedState?.sessionToken;
107
-
108
- // Use accessToken from props (never stored in sessionStorage for security)
109
- const accessToken = propAccessToken;
110
- if (!accessToken) {
111
- throw new Error("Access token not provided. Please pass accessToken as a prop.");
112
- }
113
-
114
- // Use session token from URL (source of truth) or stored state as fallback
115
- const activeSessionToken = sessionToken || storedSessionToken;
116
- if (!activeSessionToken) {
117
- throw new Error("Session token not found. Please restart the verification process.");
118
- }
119
-
120
- // Check if we're in an iframe (for iframe mode)
121
- // Wrapped in try-catch: cross-origin iframes throw SecurityError on window.top access
122
- let isInIframe = false;
123
- try {
124
- isInIframe = window.self !== window.top;
125
- } catch {
126
- isInIframe = true;
127
- }
128
-
129
- // 3. If status is already in URL params (direct redirect from backend)
130
- if (urlStatus === "verified" && verificationReference) {
131
- setStatus("success");
132
- setMessage("Guardian verified successfully! Redirecting...");
133
- onSuccess?.(verificationReference);
134
-
135
- // If in iframe, postMessage to parent instead of redirecting
136
- if (isInIframe && window.parent) {
137
- window.parent.postMessage(
138
- {
139
- type: "DIGILOCKER_VERIFICATION_STATUS",
140
- status: "verified",
141
- verificationReference,
142
- },
143
- window.location.origin
144
- );
145
- return;
146
- }
147
-
148
- redirectToOriginalPage(originalUrl, "verified", verificationReference);
149
- return;
150
- }
151
-
152
- if (urlStatus === "failed" || urlStatus === "expired") {
153
- const urlErrorCode = errorCode ?? undefined;
154
- const errorMessage = getErrorMessage(urlErrorCode);
155
- setStatus("error");
156
- setMessage("Verification failed");
157
- setErrorDetail(errorMessage);
158
- onError?.(new Error(errorMessage), urlErrorCode);
159
-
160
- // If in iframe, postMessage to parent instead of redirecting
161
- if (isInIframe && window.parent) {
162
- window.parent.postMessage(
163
- {
164
- type: "DIGILOCKER_VERIFICATION_STATUS",
165
- status: urlStatus,
166
- errorCode: urlErrorCode,
167
- error: errorMessage,
168
- },
169
- window.location.origin
170
- );
171
- return;
172
- }
173
-
174
- redirectToOriginalPage(originalUrl, urlStatus);
175
- return;
176
- }
177
-
178
- // 4. If no status in URL, poll the backend for verification status
179
- setMessage("Processing verification...");
180
-
181
- const apiBaseUrl = baseUrl || storedBaseUrl;
182
-
183
- const response = await verifyGuardianStatus({
184
- accessToken,
185
- baseUrl: apiBaseUrl,
186
- sessionToken: activeSessionToken,
187
- });
188
- if (!isMountedRef.current) return;
189
-
190
- if (response.status === "verified") {
191
- // Use top-level verification_reference first, fall back to guardian_details
192
- const verificationRef = response.verification_reference || response.guardian_details?.verification_reference || undefined;
193
-
194
- if (!verificationRef) {
195
- setStatus("error");
196
- setMessage("Verification failed");
197
- setErrorDetail("Verification completed but no reference received. Please try again.");
198
- onError?.(new Error("Verification completed but no reference received."));
199
- redirectToOriginalPage(originalUrl, "failed");
200
- return;
201
- }
202
-
203
- setStatus("success");
204
- setMessage("Guardian verified successfully! Redirecting...");
205
- onSuccess?.(verificationRef);
206
-
207
- // If in iframe, postMessage to parent instead of redirecting
208
- if (isInIframe && window.parent) {
209
- window.parent.postMessage(
210
- {
211
- type: "DIGILOCKER_VERIFICATION_STATUS",
212
- status: "verified",
213
- verificationReference: verificationRef,
214
- },
215
- window.location.origin
216
- );
217
- return;
218
- }
219
-
220
- redirectToOriginalPage(originalUrl, "verified", verificationRef);
221
- } else if (response.status === "failed" || response.status === "expired") {
222
- const responseErrorCode = response.error_code ?? undefined;
223
- const errorMessage = response.error || getErrorMessage(responseErrorCode);
224
- setStatus("error");
225
- setMessage("Verification failed");
226
- setErrorDetail(errorMessage);
227
- onError?.(new Error(errorMessage), responseErrorCode);
228
-
229
- // If in iframe, postMessage to parent instead of redirecting
230
- if (isInIframe && window.parent) {
231
- window.parent.postMessage(
232
- {
233
- type: "DIGILOCKER_VERIFICATION_STATUS",
234
- status: response.status,
235
- errorCode: responseErrorCode,
236
- error: errorMessage,
237
- },
238
- window.location.origin
239
- );
240
- return;
241
- }
242
-
243
- redirectToOriginalPage(originalUrl, response.status);
244
- } else {
245
- // Still in progress - this shouldn't happen on callback page
246
- // but handle it gracefully
247
- setMessage("Verification is still in progress. Please wait...");
248
- // Poll again after a short delay
249
- // Retry with exponential backoff before giving up
250
- const MAX_RETRIES = 3;
251
- let retryCount = 0;
252
-
253
- const attemptRetry = () => {
254
- retryCount++;
255
- const delay = 3000 * Math.pow(2, retryCount - 1); // 3s, 6s, 12s
256
- retryTimeoutRef.current = setTimeout(async () => {
257
- if (!isMountedRef.current) return;
258
- try {
259
- const retryResponse = await verifyGuardianStatus({
260
- accessToken,
261
- baseUrl: apiBaseUrl,
262
- sessionToken: activeSessionToken,
263
- });
264
- if (!isMountedRef.current) return;
265
-
266
- const retryRef = retryResponse.verification_reference || retryResponse.guardian_details?.verification_reference || undefined;
267
-
268
- if (retryResponse.status === "verified" && retryRef) {
269
- setStatus("success");
270
- setMessage("Guardian verified successfully! Redirecting...");
271
- onSuccess?.(retryRef);
272
-
273
- if (isInIframe && window.parent) {
274
- window.parent.postMessage(
275
- {
276
- type: "DIGILOCKER_VERIFICATION_STATUS",
277
- status: "verified",
278
- verificationReference: retryRef,
279
- },
280
- window.location.origin
281
- );
282
- return;
283
- }
284
-
285
- redirectToOriginalPage(originalUrl, "verified", retryRef);
286
- } else if (retryResponse.status === "failed" || retryResponse.status === "expired") {
287
- const retryErrorCode = retryResponse.error_code ?? undefined;
288
- const retryErrorMessage = retryResponse.error || getErrorMessage(retryErrorCode) || "Verification could not be completed. Please try again.";
289
- setStatus("error");
290
- setMessage("Verification failed");
291
- setErrorDetail(retryErrorMessage);
292
- onError?.(new Error(retryErrorMessage), retryErrorCode);
293
-
294
- if (isInIframe && window.parent) {
295
- window.parent.postMessage(
296
- {
297
- type: "DIGILOCKER_VERIFICATION_STATUS",
298
- status: retryResponse.status,
299
- errorCode: retryErrorCode,
300
- error: retryErrorMessage,
301
- },
302
- window.location.origin
303
- );
304
- return;
305
- }
306
-
307
- redirectToOriginalPage(originalUrl, retryResponse.status);
308
- } else if (retryCount < MAX_RETRIES) {
309
- setMessage("Verification taking longer than expected. Please wait...");
310
- attemptRetry();
311
- } else {
312
- const timeoutMessage = "Verification could not be completed in time. Please try again.";
313
- setStatus("error");
314
- setMessage("Verification failed");
315
- setErrorDetail(timeoutMessage);
316
- onError?.(new Error(timeoutMessage));
317
- redirectToOriginalPage(originalUrl, "failed");
318
- }
319
- } catch (retryErr) {
320
- if (!isMountedRef.current) return;
321
- if (retryCount < MAX_RETRIES) {
322
- attemptRetry();
323
- } else {
324
- setStatus("error");
325
- setMessage("Verification failed");
326
- setErrorDetail((retryErr as Error).message);
327
- onError?.(retryErr as Error);
328
- redirectToOriginalPage(originalUrl, "failed");
329
- }
330
- }
331
- }, delay);
332
- };
333
-
334
- attemptRetry();
335
- }
336
- } catch (error) {
337
- console.error("DigiLocker callback error:", error);
338
- setStatus("error");
339
-
340
- const err = error as Error;
341
- setMessage("Verification failed");
342
- setErrorDetail(err.message || "An error occurred during verification");
343
-
344
- onError?.(err);
345
-
346
- // Try to redirect back even on error
347
- const persistedState = getConsentState();
348
- if (persistedState?.originalUrl) {
349
- redirectTimeoutRef.current = setTimeout(() => {
350
- redirectToOriginalPage(persistedState.originalUrl, "failed");
351
- }, 3000);
352
- }
353
- }
354
- }, [propAccessToken, baseUrl, onSuccess, onError, redirectToOriginalPage]);
355
-
356
- useEffect(() => {
357
- injectCheckboxStyles();
358
- handleCallback();
359
- return () => {
360
- isMountedRef.current = false;
361
- if (retryTimeoutRef.current) clearTimeout(retryTimeoutRef.current);
362
- if (redirectTimeoutRef.current) clearTimeout(redirectTimeoutRef.current);
363
- };
364
- }, [handleCallback]);
365
-
366
- const handleRetry = useCallback(() => {
367
- const persistedState = getConsentState();
368
- if (persistedState?.originalUrl) {
369
- clearConsentState();
370
- window.location.href = persistedState.originalUrl;
371
- } else {
372
- window.location.href = "/";
373
- }
374
- }, []);
375
-
376
- // --- Styles ---
377
-
378
- const containerStyle: React.CSSProperties = {
379
- display: "flex",
380
- alignItems: "center",
381
- justifyContent: "center",
382
- minHeight: "100vh",
383
- backgroundColor: "#f8fafc",
384
- fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
385
- padding: "24px",
386
- boxSizing: "border-box",
387
- };
388
-
389
- const cardStyle: React.CSSProperties = {
390
- backgroundColor: "#ffffff",
391
- borderRadius: "16px",
392
- boxShadow: "0 1px 3px rgba(0, 0, 0, 0.08), 0 8px 30px rgba(0, 0, 0, 0.06)",
393
- padding: "48px 40px 40px",
394
- textAlign: "center",
395
- maxWidth: "420px",
396
- width: "100%",
397
- };
398
-
399
- const spinnerContainerStyle: React.CSSProperties = {
400
- width: "72px",
401
- height: "72px",
402
- margin: "0 auto 28px",
403
- position: "relative",
404
- };
405
-
406
- const spinnerStyle: React.CSSProperties = {
407
- width: "72px",
408
- height: "72px",
409
- border: "3px solid #e5e7eb",
410
- borderTopColor: "#4f87ff",
411
- borderRadius: "50%",
412
- animation: "redacto-dl-spin 0.8s linear infinite",
413
- boxSizing: "border-box",
414
- };
415
-
416
- const iconContainerStyle: React.CSSProperties = {
417
- width: "72px",
418
- height: "72px",
419
- borderRadius: "50%",
420
- display: "flex",
421
- alignItems: "center",
422
- justifyContent: "center",
423
- margin: "0 auto 28px",
424
- animation: "redacto-dl-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards",
425
- position: "relative",
426
- };
427
-
428
- const successIconStyle: React.CSSProperties = {
429
- ...iconContainerStyle,
430
- backgroundColor: "#d1fae5",
431
- color: "#059669",
432
- };
433
-
434
- const errorIconStyle: React.CSSProperties = {
435
- ...iconContainerStyle,
436
- backgroundColor: "#fee2e2",
437
- color: "#dc2626",
438
- };
439
-
440
- const titleStyle: React.CSSProperties = {
441
- fontSize: "22px",
442
- fontWeight: 700,
443
- color: "#111827",
444
- margin: "0 0 8px 0",
445
- letterSpacing: "-0.01em",
446
- };
447
-
448
- const messageStyle: React.CSSProperties = {
449
- fontSize: "14px",
450
- color: "#6b7280",
451
- marginBottom: "0",
452
- lineHeight: 1.6,
453
- };
454
-
455
- const subtextStyle: React.CSSProperties = {
456
- fontSize: "13px",
457
- color: "#9ca3af",
458
- marginTop: "16px",
459
- lineHeight: 1.5,
460
- };
461
-
462
- const errorDetailStyle: React.CSSProperties = {
463
- fontSize: "13px",
464
- color: "#dc2626",
465
- marginTop: "16px",
466
- padding: "12px 16px",
467
- backgroundColor: "#fef2f2",
468
- borderRadius: "10px",
469
- border: "1px solid #fecaca",
470
- lineHeight: 1.5,
471
- textAlign: "left",
472
- };
473
-
474
- const buttonStyle: React.CSSProperties = {
475
- marginTop: "24px",
476
- padding: "12px 28px",
477
- backgroundColor: "#4f87ff",
478
- color: "#ffffff",
479
- border: "none",
480
- borderRadius: "10px",
481
- fontSize: "15px",
482
- fontWeight: 600,
483
- cursor: "pointer",
484
- transition: "background-color 0.2s, transform 0.15s",
485
- width: "100%",
486
- };
487
-
488
- const keyframesStyle = `
489
- @keyframes redacto-dl-spin {
490
- to { transform: rotate(360deg); }
491
- }
492
- @keyframes redacto-dl-pop {
493
- 0% { transform: scale(0.3); opacity: 0; }
494
- 60% { transform: scale(1.08); opacity: 1; }
495
- 100% { transform: scale(1); opacity: 1; }
496
- }
497
- @keyframes redacto-dl-check {
498
- 0% { stroke-dashoffset: 24; }
499
- 100% { stroke-dashoffset: 0; }
500
- }
501
- @keyframes redacto-dl-pulse {
502
- 0%, 100% { transform: scale(1); opacity: 0.6; }
503
- 50% { transform: scale(1.15); opacity: 0; }
504
- }
505
- .redacto-dl-retry-btn:hover {
506
- background-color: #3d6fdb !important;
507
- transform: translateY(-1px);
508
- }
509
- .redacto-dl-retry-btn:active {
510
- transform: translateY(0);
511
- }
512
- `;
513
-
514
- return (
515
- <>
516
- <style dangerouslySetInnerHTML={{ __html: keyframesStyle }} />
517
- <div style={containerStyle}>
518
- <div style={cardStyle}>
519
- {status === "processing" && (
520
- <>
521
- <div style={spinnerContainerStyle}>
522
- <div style={spinnerStyle} />
523
- </div>
524
- <h2 style={titleStyle}>Processing Verification</h2>
525
- <p style={messageStyle}>{message}</p>
526
- <p style={subtextStyle}>
527
- Please wait while we verify your guardian's identity...
528
- </p>
529
- </>
530
- )}
531
-
532
- {status === "success" && (
533
- <>
534
- <div style={{ position: "relative", width: "72px", height: "72px", margin: "0 auto 28px" }}>
535
- {/* Pulse ring */}
536
- <div style={{
537
- position: "absolute",
538
- inset: "-8px",
539
- borderRadius: "50%",
540
- border: "2px solid #d1fae5",
541
- animation: "redacto-dl-pulse 1.5s ease-out infinite",
542
- }} />
543
- <div style={successIconStyle}>
544
- <svg
545
- width="30"
546
- height="30"
547
- viewBox="0 0 24 24"
548
- fill="none"
549
- stroke="currentColor"
550
- strokeWidth="2.5"
551
- strokeLinecap="round"
552
- strokeLinejoin="round"
553
- style={{ strokeDasharray: 24, animation: "redacto-dl-check 0.4s ease-out 0.3s forwards", strokeDashoffset: 24 }}
554
- >
555
- <polyline points="20 6 9 17 4 12" />
556
- </svg>
557
- </div>
558
- </div>
559
- <h2 style={titleStyle}>Verification Successful</h2>
560
- <p style={messageStyle}>{message}</p>
561
- <p style={subtextStyle}>
562
- You will be redirected automatically.
563
- </p>
564
- </>
565
- )}
566
-
567
- {status === "error" && (
568
- <>
569
- <div style={errorIconStyle}>
570
- <svg
571
- width="30"
572
- height="30"
573
- viewBox="0 0 24 24"
574
- fill="none"
575
- stroke="currentColor"
576
- strokeWidth="2.5"
577
- strokeLinecap="round"
578
- strokeLinejoin="round"
579
- >
580
- <line x1="18" y1="6" x2="6" y2="18" />
581
- <line x1="6" y1="6" x2="18" y2="18" />
582
- </svg>
583
- </div>
584
- <h2 style={titleStyle}>Verification Failed</h2>
585
- <p style={messageStyle}>{message}</p>
586
- {errorDetail && <p style={errorDetailStyle}>{errorDetail}</p>}
587
- <button
588
- className="redacto-dl-retry-btn"
589
- style={buttonStyle}
590
- onClick={handleRetry}
591
- >
592
- Try Again
593
- </button>
594
- </>
595
- )}
596
- </div>
597
- </div>
598
- </>
599
- );
600
- };
601
-
602
- export default DigiLockerCallback;
@@ -1,7 +0,0 @@
1
- /**
2
- * Consent SDK Components
3
- *
4
- * Export reusable components for the consent flow.
5
- */
6
-
7
- export { DigiLockerCallback } from "./DigiLockerCallback";
@@ -1,20 +0,0 @@
1
- import type { DpoInfoAudioKey } from "./api/types";
2
-
3
- /**
4
- * Maps DPO info audio URL keys to their corresponding DOM element IDs.
5
- * Used by both audioSequence and elementIdSequence builders to keep them in sync.
6
- * Order determines playback sequence: grievance → dp board → dpo.
7
- */
8
- export const DPO_AUDIO_ELEMENT_MAP: ReadonlyArray<{
9
- audioKey: DpoInfoAudioKey;
10
- elementId: string;
11
- }> = [
12
- { audioKey: "grievance_text_audio_url", elementId: "dpo-grievance-text" },
13
- { audioKey: "grievance_anchor_text_audio_url", elementId: "dpo-grievance-link" },
14
- { audioKey: "grievance_email_connector_text_audio_url", elementId: "dpo-grievance-email-connector" },
15
- { audioKey: "grievance_email_audio_url", elementId: "dpo-grievance-email" },
16
- { audioKey: "dp_board_text_audio_url", elementId: "dpo-dp-board-text" },
17
- { audioKey: "dp_board_anchor_text_audio_url", elementId: "dpo-dp-board-link" },
18
- { audioKey: "dpo_text_audio_url", elementId: "dpo-dpo-text" },
19
- { audioKey: "dpo_anchor_text_audio_url", elementId: "dpo-dpo-link" },
20
- ] as const;
@@ -1 +0,0 @@
1
- export { RedactoNoticeConsent as default } from "./RedactoNoticeConsent";