@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.
- package/NOTICE.md +17 -0
- package/README.md +67 -3
- package/dist/chunk-FEGTW73Q.mjs +182 -0
- package/dist/fonts.d.mts +35 -0
- package/dist/fonts.d.ts +35 -0
- package/dist/fonts.js +183 -0
- package/dist/fonts.mjs +10 -0
- package/dist/index.d.mts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +613 -249
- package/dist/index.mjs +235 -85
- package/dist/montserrat.generated-NBTECYRW.mjs +22 -0
- package/dist/types-6Aj7faxL.d.mts +57 -0
- package/dist/types-6Aj7faxL.d.ts +57 -0
- package/package.json +10 -1
- package/.turbo/turbo-build.log +0 -22
- package/.turbo/turbo-test.log +0 -203
- package/.turbo/turbo-verify-pack.log +0 -6
- package/CHANGELOG.md +0 -383
- package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.test.tsx +0 -934
- package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.tsx +0 -2160
- package/src/RedactoNoticeAssisted/api/index.ts +0 -275
- package/src/RedactoNoticeAssisted/api/types.ts +0 -182
- package/src/RedactoNoticeAssisted/assets/redacto-logo.png +0 -0
- package/src/RedactoNoticeAssisted/constants.ts +0 -51
- package/src/RedactoNoticeAssisted/i18n.ts +0 -1408
- package/src/RedactoNoticeAssisted/index.ts +0 -1
- package/src/RedactoNoticeAssisted/injectStyles.ts +0 -251
- package/src/RedactoNoticeAssisted/styles.ts +0 -730
- package/src/RedactoNoticeAssisted/types.ts +0 -26
- package/src/RedactoNoticeAssisted/useMediaQuery.ts +0 -36
- package/src/RedactoNoticeConsent/RedactoNoticeConsent.test.tsx +0 -1186
- package/src/RedactoNoticeConsent/RedactoNoticeConsent.tsx +0 -4299
- package/src/RedactoNoticeConsent/api/index.ts +0 -486
- package/src/RedactoNoticeConsent/api/sandbox.ts +0 -150
- package/src/RedactoNoticeConsent/api/types.ts +0 -505
- package/src/RedactoNoticeConsent/assets/redacto-logo.png +0 -0
- package/src/RedactoNoticeConsent/components/DigiLockerCallback.tsx +0 -602
- package/src/RedactoNoticeConsent/components/index.ts +0 -7
- package/src/RedactoNoticeConsent/constants.ts +0 -20
- package/src/RedactoNoticeConsent/index.ts +0 -1
- package/src/RedactoNoticeConsent/injectStyles.ts +0 -151
- package/src/RedactoNoticeConsent/language-codes.ts +0 -95
- package/src/RedactoNoticeConsent/services/storage.ts +0 -122
- package/src/RedactoNoticeConsent/styles.ts +0 -409
- package/src/RedactoNoticeConsent/types.ts +0 -80
- package/src/RedactoNoticeConsent/useMediaQuery.ts +0 -36
- package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.test.tsx +0 -369
- package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.tsx +0 -709
- package/src/RedactoNoticeConsentInline/api/index.ts +0 -115
- package/src/RedactoNoticeConsentInline/api/notice-read-routing.test.ts +0 -72
- package/src/RedactoNoticeConsentInline/api/types.ts +0 -185
- package/src/RedactoNoticeConsentInline/assets/redacto-logo.png +0 -0
- package/src/RedactoNoticeConsentInline/index.ts +0 -1
- package/src/RedactoNoticeConsentInline/injectStyles.ts +0 -40
- package/src/RedactoNoticeConsentInline/styles.ts +0 -397
- package/src/RedactoNoticeConsentInline/types.ts +0 -51
- package/src/RedactoNoticeConsentInline/useMediaQuery.ts +0 -36
- package/src/RedactoPrivacyCenter/NotificationsPage.tsx +0 -182
- package/src/RedactoPrivacyCenter/PrivacyCenterActivityPage.tsx +0 -19
- package/src/RedactoPrivacyCenter/PrivacyCenterCaseDetailsPage.tsx +0 -156
- package/src/RedactoPrivacyCenter/PrivacyCenterConsentManagerPage.tsx +0 -17
- package/src/RedactoPrivacyCenter/PrivacyCenterFormPage.tsx +0 -79
- package/src/RedactoPrivacyCenter/PrivacyCenterHomePage.tsx +0 -36
- package/src/RedactoPrivacyCenter/PrivacyCenterLayout.tsx +0 -177
- package/src/RedactoPrivacyCenter/PrivacyCenterMyReceiptPage.tsx +0 -26
- package/src/RedactoPrivacyCenter/RedactoPrivacyCenter.tsx +0 -93
- package/src/RedactoPrivacyCenter/api/actions.ts +0 -682
- package/src/RedactoPrivacyCenter/api/client.ts +0 -1003
- package/src/RedactoPrivacyCenter/api/config.ts +0 -33
- package/src/RedactoPrivacyCenter/api/fetcher.ts +0 -275
- package/src/RedactoPrivacyCenter/api/orgBranding.ts +0 -16
- package/src/RedactoPrivacyCenter/api/upload.ts +0 -93
- package/src/RedactoPrivacyCenter/assets/character.svg +0 -31
- package/src/RedactoPrivacyCenter/assets/fileAttach.svg +0 -9
- package/src/RedactoPrivacyCenter/assets/greenTick.svg +0 -4
- package/src/RedactoPrivacyCenter/assets/mail.svg +0 -3
- package/src/RedactoPrivacyCenter/assets/poweredByRedacto.svg +0 -9
- package/src/RedactoPrivacyCenter/assets/sentImg.svg +0 -9
- package/src/RedactoPrivacyCenter/assets/uploadFileIcon.svg +0 -9
- package/src/RedactoPrivacyCenter/components/ActivitiesList.tsx +0 -252
- package/src/RedactoPrivacyCenter/components/ActivityTimeline.tsx +0 -239
- package/src/RedactoPrivacyCenter/components/AppShell/AppShell.tsx +0 -268
- package/src/RedactoPrivacyCenter/components/AppShell/MobileNavDrawer.tsx +0 -218
- package/src/RedactoPrivacyCenter/components/AppShell/NavItem.tsx +0 -205
- package/src/RedactoPrivacyCenter/components/AppShell/PageHeader.tsx +0 -107
- package/src/RedactoPrivacyCenter/components/AppShell/SidebarNav.tsx +0 -100
- package/src/RedactoPrivacyCenter/components/AppShell/TopAppBar.tsx +0 -339
- package/src/RedactoPrivacyCenter/components/AppShell/UserMenu.tsx +0 -245
- package/src/RedactoPrivacyCenter/components/AppShell/hooks/useIsTruncated.ts +0 -28
- package/src/RedactoPrivacyCenter/components/AppShell/hooks/useKeyboardShortcut.ts +0 -40
- package/src/RedactoPrivacyCenter/components/AppShell/hooks/useSidebarState.ts +0 -62
- package/src/RedactoPrivacyCenter/components/AppShell/usePrivacyCenterExitAction.ts +0 -36
- package/src/RedactoPrivacyCenter/components/CaseDetails/AttachmentCard.tsx +0 -38
- package/src/RedactoPrivacyCenter/components/CaseDetails/ChatBubble.tsx +0 -31
- package/src/RedactoPrivacyCenter/components/CaseDetails/DocumentRequestCard.tsx +0 -79
- package/src/RedactoPrivacyCenter/components/CaseDetails/FinalizedTooltipWrapper.tsx +0 -25
- package/src/RedactoPrivacyCenter/components/CaseDetails/MessageComposer.tsx +0 -96
- package/src/RedactoPrivacyCenter/components/CaseDetails/MessageItem.tsx +0 -97
- package/src/RedactoPrivacyCenter/components/CaseDetails/MessagesTab.tsx +0 -156
- package/src/RedactoPrivacyCenter/components/CaseDetails/RequestDetailsTab.tsx +0 -171
- package/src/RedactoPrivacyCenter/components/CaseDetails/StatusEvent.tsx +0 -23
- package/src/RedactoPrivacyCenter/components/CaseDetails/useFileUpload.ts +0 -116
- package/src/RedactoPrivacyCenter/components/CaseDetails/useMessagePolling.ts +0 -43
- package/src/RedactoPrivacyCenter/components/CaseDetails/utils.ts +0 -71
- package/src/RedactoPrivacyCenter/components/CaseDetailsModal.tsx +0 -469
- package/src/RedactoPrivacyCenter/components/CaseHistory.tsx +0 -426
- package/src/RedactoPrivacyCenter/components/ConsentManager.tsx +0 -1199
- package/src/RedactoPrivacyCenter/components/ConsentManagerCells.tsx +0 -201
- package/src/RedactoPrivacyCenter/components/ConsentManagerColumns.tsx +0 -138
- package/src/RedactoPrivacyCenter/components/ConsentManagerConstants.ts +0 -7
- package/src/RedactoPrivacyCenter/components/ConsentManagerExpandedRow.tsx +0 -179
- package/src/RedactoPrivacyCenter/components/ConsentManagerGroupedColumns.tsx +0 -318
- package/src/RedactoPrivacyCenter/components/ConsentManagerProductCards.tsx +0 -333
- package/src/RedactoPrivacyCenter/components/ConsentManagerPurposeCards.tsx +0 -102
- package/src/RedactoPrivacyCenter/components/ConsentManagerTableSkeleton.tsx +0 -159
- package/src/RedactoPrivacyCenter/components/DataRequest/CorrectionDataSection.tsx +0 -189
- package/src/RedactoPrivacyCenter/components/DataRequest/GrievanceDataSection.tsx +0 -118
- package/src/RedactoPrivacyCenter/components/DataRequest/NominationDataSection.tsx +0 -66
- package/src/RedactoPrivacyCenter/components/DataRequest/ProductSelectionSection.tsx +0 -222
- package/src/RedactoPrivacyCenter/components/DataRequest/PurposeSelectionSection.tsx +0 -331
- package/src/RedactoPrivacyCenter/components/Form.tsx +0 -1821
- package/src/RedactoPrivacyCenter/components/GrievanceTable.tsx +0 -174
- package/src/RedactoPrivacyCenter/components/GrievanceTablePagination.tsx +0 -337
- package/src/RedactoPrivacyCenter/components/ModifyConsentModal.tsx +0 -334
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationBell.tsx +0 -173
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationCTAButton.tsx +0 -18
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationDropdown.tsx +0 -54
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationDropdownItem.tsx +0 -57
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationIcon.tsx +0 -19
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationListPanel.tsx +0 -92
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationRefreshButton.tsx +0 -20
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationRow.tsx +0 -58
- package/src/RedactoPrivacyCenter/components/NotificationHub/StatCard.tsx +0 -10
- package/src/RedactoPrivacyCenter/components/NotificationHub/useNotificationActions.ts +0 -112
- package/src/RedactoPrivacyCenter/components/NotificationHub/utils.ts +0 -27
- package/src/RedactoPrivacyCenter/components/Pagination.tsx +0 -140
- package/src/RedactoPrivacyCenter/components/PrivacyCenterEmptyState.tsx +0 -76
- package/src/RedactoPrivacyCenter/components/PrivacyCenterSessionExpired.tsx +0 -97
- package/src/RedactoPrivacyCenter/components/ReceiptsList.tsx +0 -454
- package/src/RedactoPrivacyCenter/components/RequestSubmit.tsx +0 -270
- package/src/RedactoPrivacyCenter/components/SelectUser.tsx +0 -95
- package/src/RedactoPrivacyCenter/components/SelectUserGate.tsx +0 -195
- package/src/RedactoPrivacyCenter/components/SideMenuBarPC/constants.tsx +0 -25
- package/src/RedactoPrivacyCenter/components/SideMenuBarPC/types.ts +0 -21
- package/src/RedactoPrivacyCenter/components/caseHistoryColumns.tsx +0 -159
- package/src/RedactoPrivacyCenter/components/constant.ts +0 -52
- package/src/RedactoPrivacyCenter/components/groupHelpers.ts +0 -155
- package/src/RedactoPrivacyCenter/components/receiptColumns.tsx +0 -203
- package/src/RedactoPrivacyCenter/components/types.ts +0 -123
- package/src/RedactoPrivacyCenter/components/utils.tsx +0 -10
- package/src/RedactoPrivacyCenter/config/routes.ts +0 -9
- package/src/RedactoPrivacyCenter/config/table.ts +0 -25
- package/src/RedactoPrivacyCenter/context/AuthContext.tsx +0 -252
- package/src/RedactoPrivacyCenter/context/BaseUrlContext.tsx +0 -47
- package/src/RedactoPrivacyCenter/context/BrandingContext.tsx +0 -52
- package/src/RedactoPrivacyCenter/context/DataAvailabilityContext.session-expired.test.tsx +0 -92
- package/src/RedactoPrivacyCenter/context/DataAvailabilityContext.tsx +0 -181
- package/src/RedactoPrivacyCenter/context/LocaleContext.tsx +0 -11
- package/src/RedactoPrivacyCenter/context/NavigationContext.tsx +0 -96
- package/src/RedactoPrivacyCenter/context/OrganizationContext.tsx +0 -30
- package/src/RedactoPrivacyCenter/context/PageChromeContext.tsx +0 -80
- package/src/RedactoPrivacyCenter/context/ProfileSwitchContext.tsx +0 -15
- package/src/RedactoPrivacyCenter/context/types.ts +0 -57
- package/src/RedactoPrivacyCenter/lib/api.ts +0 -759
- package/src/RedactoPrivacyCenter/lib/consent-manager/utils.tsx +0 -67
- package/src/RedactoPrivacyCenter/lib/constants.ts +0 -283
- package/src/RedactoPrivacyCenter/lib/i18n.ts +0 -81
- package/src/RedactoPrivacyCenter/lib/locales.ts +0 -102
- package/src/RedactoPrivacyCenter/lib/queries.ts +0 -141
- package/src/RedactoPrivacyCenter/lib/sandbox.ts +0 -104
- package/src/RedactoPrivacyCenter/lib/types.ts +0 -892
- package/src/RedactoPrivacyCenter/lib/useCurrentLanguage.ts +0 -37
- package/src/RedactoPrivacyCenter/lib/utils.refresh-circuit.test.ts +0 -127
- package/src/RedactoPrivacyCenter/lib/utils.refresh-storage.test.ts +0 -85
- package/src/RedactoPrivacyCenter/lib/utils.session-expired.test.ts +0 -109
- package/src/RedactoPrivacyCenter/lib/utils.ts +0 -798
- package/src/RedactoPrivacyCenter/locales/as/translation.json +0 -340
- package/src/RedactoPrivacyCenter/locales/bn/translation.json +0 -340
- package/src/RedactoPrivacyCenter/locales/brx/translation.json +0 -340
- package/src/RedactoPrivacyCenter/locales/doi/translation.json +0 -340
- package/src/RedactoPrivacyCenter/locales/en/translation.json +0 -355
- package/src/RedactoPrivacyCenter/locales/gom/translation.json +0 -340
- package/src/RedactoPrivacyCenter/locales/gu/translation.json +0 -340
- package/src/RedactoPrivacyCenter/locales/hi/translation.json +0 -343
- package/src/RedactoPrivacyCenter/locales/kn/translation.json +0 -340
- package/src/RedactoPrivacyCenter/locales/ks/translation.json +0 -340
- package/src/RedactoPrivacyCenter/locales/mai/translation.json +0 -340
- package/src/RedactoPrivacyCenter/locales/ml/translation.json +0 -340
- package/src/RedactoPrivacyCenter/locales/mni-Mtei/translation.json +0 -340
- package/src/RedactoPrivacyCenter/locales/mr/translation.json +0 -340
- package/src/RedactoPrivacyCenter/locales/ne/translation.json +0 -340
- package/src/RedactoPrivacyCenter/locales/or/translation.json +0 -340
- package/src/RedactoPrivacyCenter/locales/pa/translation.json +0 -340
- package/src/RedactoPrivacyCenter/locales/sa/translation.json +0 -340
- package/src/RedactoPrivacyCenter/locales/sat/translation.json +0 -340
- package/src/RedactoPrivacyCenter/locales/sd/translation.json +0 -340
- package/src/RedactoPrivacyCenter/locales/ta/translation.json +0 -340
- package/src/RedactoPrivacyCenter/locales/te/translation.json +0 -340
- package/src/RedactoPrivacyCenter/locales/ur/translation.json +0 -340
- package/src/RedactoPrivacyCenter/styles/applyBrandingTheme.ts +0 -66
- package/src/RedactoPrivacyCenter/styles/base.css +0 -117
- package/src/RedactoPrivacyCenter/styles/injectStyles.ts +0 -3108
- package/src/RedactoPrivacyCenter/styles/pcStyles.ts +0 -831
- package/src/RedactoPrivacyCenter/styles/responsive.ts +0 -138
- package/src/RedactoPrivacyCenter/styles/variables.css +0 -96
- package/src/RedactoPrivacyCenter/table/AdvancedTable.tsx +0 -387
- package/src/RedactoPrivacyCenter/table/AdvancedTablePagination.tsx +0 -468
- package/src/RedactoPrivacyCenter/table/index.ts +0 -2
- package/src/RedactoPrivacyCenter/types/images.d.ts +0 -29
- package/src/RedactoPrivacyCenter/ui/Footer.tsx +0 -69
- package/src/RedactoPrivacyCenter/ui/FormBlockWrapper.tsx +0 -54
- package/src/RedactoPrivacyCenter/ui/PCAccordion.tsx +0 -93
- package/src/RedactoPrivacyCenter/ui/PCActionIcon.tsx +0 -47
- package/src/RedactoPrivacyCenter/ui/PCAvatar.test.tsx +0 -83
- package/src/RedactoPrivacyCenter/ui/PCAvatar.tsx +0 -93
- package/src/RedactoPrivacyCenter/ui/PCBadge.tsx +0 -48
- package/src/RedactoPrivacyCenter/ui/PCButton.tsx +0 -77
- package/src/RedactoPrivacyCenter/ui/PCCheckbox.tsx +0 -55
- package/src/RedactoPrivacyCenter/ui/PCCollapse.tsx +0 -107
- package/src/RedactoPrivacyCenter/ui/PCEmpty.tsx +0 -35
- package/src/RedactoPrivacyCenter/ui/PCInput.tsx +0 -132
- package/src/RedactoPrivacyCenter/ui/PCLoader.tsx +0 -31
- package/src/RedactoPrivacyCenter/ui/PCModal.tsx +0 -106
- package/src/RedactoPrivacyCenter/ui/PCPopover.tsx +0 -206
- package/src/RedactoPrivacyCenter/ui/PCSelect.tsx +0 -433
- package/src/RedactoPrivacyCenter/ui/PCTable.tsx +0 -149
- package/src/RedactoPrivacyCenter/ui/PCText.tsx +0 -41
- package/src/RedactoPrivacyCenter/ui/PCTextarea.tsx +0 -43
- package/src/RedactoPrivacyCenter/ui/PCTitle.tsx +0 -37
- package/src/RedactoPrivacyCenter/ui/PCTooltip.tsx +0 -121
- package/src/RedactoPrivacyCenter/ui/SimpleBar.tsx +0 -25
- package/src/RedactoPrivacyCenter/ui/StatusBadge.tsx +0 -53
- package/src/RedactoPrivacyCenter/ui/index.ts +0 -18
- package/src/RedactoPrivacyCenter/utils/cn.ts +0 -28
- package/src/RedactoPrivacyCenter/utils/date.ts +0 -48
- package/src/RedactoPrivacyCenter/utils/status.ts +0 -111
- package/src/RedactoPrivacyCenter/utils/toast.ts +0 -130
- package/src/index.ts +0 -19
- package/src/privacy-center.ts +0 -113
- package/src/shared/api-errors.ts +0 -180
- package/src/shared/notice-consent-status.ts +0 -190
- package/src/shared/sandbox.ts +0 -6
- package/src/types/css.d.ts +0 -4
- package/src/types/images.d.ts +0 -19
- package/src/types/react-jsx.d.ts +0 -26
- package/tests/DataAvailabilityContext.test.tsx +0 -123
- package/tests/Form.test.tsx +0 -1424
- package/tests/ProductSelectionSection.test.tsx +0 -328
- package/tests/RequestSubmit.test.tsx +0 -135
- package/tests/RevokeWarningMessage.test.tsx +0 -151
- package/tests/consentClient.test.ts +0 -217
- package/tests/manageConsentServer.test.ts +0 -38
- package/tests/mocks.ts +0 -257
- package/tests/resolveContactFromJwt.test.ts +0 -44
- package/tests/setup.ts +0 -16
- package/tsconfig.json +0 -16
- package/tsup.config.ts +0 -31
- package/vitest.config.ts +0 -16
|
@@ -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;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { resolveContactFromJwt } from '../src/RedactoPrivacyCenter/lib/utils';
|
|
4
|
-
|
|
5
|
-
describe('resolveContactFromJwt', () => {
|
|
6
|
-
it('prefers the email when present in user_data', () => {
|
|
7
|
-
const decoded = {
|
|
8
|
-
user_data: {
|
|
9
|
-
primary_email: 'user@example.com',
|
|
10
|
-
primary_mobile: '+918955610253',
|
|
11
|
-
org_user_id: '+918955610253',
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
expect(resolveContactFromJwt(decoded)).toBe('user@example.com');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('falls back to the mobile for a mobile-only login (no email)', () => {
|
|
18
|
-
const decoded = {
|
|
19
|
-
user_data: {
|
|
20
|
-
primary_email: null,
|
|
21
|
-
primary_mobile: '+918955610253',
|
|
22
|
-
org_user_id: '+918955610253',
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
expect(resolveContactFromJwt(decoded)).toBe('+918955610253');
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('falls back to org_user_id when neither email nor mobile is present', () => {
|
|
29
|
-
const decoded = { user_data: { org_user_id: 'ucid-123' } };
|
|
30
|
-
expect(resolveContactFromJwt(decoded)).toBe('ucid-123');
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('reads top-level contact / primary_email when not nested', () => {
|
|
34
|
-
expect(resolveContactFromJwt({ contact: 'a@b.com' })).toBe('a@b.com');
|
|
35
|
-
expect(resolveContactFromJwt({ primary_email: 'c@d.com' })).toBe('c@d.com');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('returns null for missing, empty, or whitespace identifiers', () => {
|
|
39
|
-
expect(resolveContactFromJwt(null)).toBeNull();
|
|
40
|
-
expect(resolveContactFromJwt({})).toBeNull();
|
|
41
|
-
expect(resolveContactFromJwt({ user_data: {} })).toBeNull();
|
|
42
|
-
expect(resolveContactFromJwt({ user_data: { primary_mobile: ' ' } })).toBeNull();
|
|
43
|
-
});
|
|
44
|
-
});
|
package/tests/setup.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import "@testing-library/jest-dom";
|
|
2
|
-
|
|
3
|
-
// Mock window.matchMedia
|
|
4
|
-
Object.defineProperty(window, "matchMedia", {
|
|
5
|
-
writable: true,
|
|
6
|
-
value: (query: string) => ({
|
|
7
|
-
matches: false,
|
|
8
|
-
media: query,
|
|
9
|
-
onchange: null,
|
|
10
|
-
addListener: vi.fn(), // deprecated
|
|
11
|
-
removeListener: vi.fn(), // deprecated
|
|
12
|
-
addEventListener: vi.fn(),
|
|
13
|
-
removeEventListener: vi.fn(),
|
|
14
|
-
dispatchEvent: vi.fn(),
|
|
15
|
-
}),
|
|
16
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2019",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"declaration": true,
|
|
6
|
-
"strict": true,
|
|
7
|
-
"jsx": "react-jsx",
|
|
8
|
-
"moduleResolution": "node",
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"resolveJsonModule": true,
|
|
12
|
-
"types": ["react", "react-dom"],
|
|
13
|
-
"plugins": [{ "name": "typescript-plugin-css-modules" }]
|
|
14
|
-
},
|
|
15
|
-
"include": ["src"]
|
|
16
|
-
}
|
package/tsup.config.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "tsup";
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
entry: {
|
|
5
|
-
index: "src/index.ts",
|
|
6
|
-
"privacy-center": "src/privacy-center.ts",
|
|
7
|
-
},
|
|
8
|
-
format: ["esm", "cjs"],
|
|
9
|
-
dts: true,
|
|
10
|
-
external: [
|
|
11
|
-
"react",
|
|
12
|
-
"react-dom",
|
|
13
|
-
"jwt-decode",
|
|
14
|
-
"@tanstack/react-query",
|
|
15
|
-
"@tanstack/react-table",
|
|
16
|
-
"i18next",
|
|
17
|
-
"i18next-browser-languagedetector",
|
|
18
|
-
"react-i18next",
|
|
19
|
-
"lucide-react",
|
|
20
|
-
"react-icons",
|
|
21
|
-
"dayjs",
|
|
22
|
-
"lodash",
|
|
23
|
-
],
|
|
24
|
-
clean: true,
|
|
25
|
-
loader: {
|
|
26
|
-
".png": "dataurl",
|
|
27
|
-
".jpg": "dataurl",
|
|
28
|
-
".svg": "dataurl",
|
|
29
|
-
".css": "local-css",
|
|
30
|
-
},
|
|
31
|
-
});
|
package/vitest.config.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "vitest/config";
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
test: {
|
|
5
|
-
environment: "jsdom",
|
|
6
|
-
globals: true,
|
|
7
|
-
setupFiles: ["./tests/setup.ts"],
|
|
8
|
-
coverage: {
|
|
9
|
-
provider: "v8",
|
|
10
|
-
reporter: ["text", "html"],
|
|
11
|
-
reportsDirectory: "./coverage",
|
|
12
|
-
clean: false, // Prevent cleaning coverage folder before tests
|
|
13
|
-
cleanOnRerun: false, // Prevent cleaning coverage folder after tests
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
});
|