@redacto.io/consent-sdk-react 10.0.0-beta.0 → 10.0.0-beta.2

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 (66) hide show
  1. package/.turbo/turbo-build.log +22 -25
  2. package/CHANGELOG.md +20 -0
  3. package/dist/index.d.mts +13 -6
  4. package/dist/index.d.ts +13 -6
  5. package/dist/index.js +6 -8
  6. package/dist/index.mjs +6 -8
  7. package/dist/privacy-center.d.mts +62 -27
  8. package/dist/privacy-center.d.ts +62 -27
  9. package/dist/privacy-center.js +1940 -1365
  10. package/dist/privacy-center.mjs +1864 -1284
  11. package/package.json +1 -1
  12. package/src/RedactoNoticeConsent/RedactoNoticeConsent.tsx +1 -0
  13. package/src/RedactoNoticeConsent/api/index.ts +4 -4
  14. package/src/RedactoNoticeConsent/api/types.ts +3 -2
  15. package/src/RedactoNoticeConsent/types.ts +1 -1
  16. package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.tsx +1 -0
  17. package/src/RedactoNoticeConsentInline/api/index.ts +4 -4
  18. package/src/RedactoNoticeConsentInline/api/types.ts +2 -1
  19. package/src/RedactoNoticeConsentInline/types.ts +1 -1
  20. package/src/RedactoPrivacyCenter/PrivacyCenterLayout.tsx +8 -5
  21. package/src/RedactoPrivacyCenter/RedactoPrivacyCenter.tsx +1 -1
  22. package/src/RedactoPrivacyCenter/api/actions.ts +24 -5
  23. package/src/RedactoPrivacyCenter/api/client.ts +101 -21
  24. package/src/RedactoPrivacyCenter/components/AppShell/UserMenu.tsx +64 -35
  25. package/src/RedactoPrivacyCenter/components/ConsentManager.tsx +7 -0
  26. package/src/RedactoPrivacyCenter/components/ConsentManagerCells.tsx +19 -2
  27. package/src/RedactoPrivacyCenter/components/Form.tsx +7 -3
  28. package/src/RedactoPrivacyCenter/components/ModifyConsentModal.tsx +1 -1
  29. package/src/RedactoPrivacyCenter/components/SelectUser.tsx +83 -0
  30. package/src/RedactoPrivacyCenter/components/SelectUserGate.tsx +193 -0
  31. package/src/RedactoPrivacyCenter/components/constant.ts +11 -0
  32. package/src/RedactoPrivacyCenter/context/BaseUrlContext.tsx +1 -1
  33. package/src/RedactoPrivacyCenter/context/ProfileSwitchContext.tsx +15 -0
  34. package/src/RedactoPrivacyCenter/context/types.ts +1 -1
  35. package/src/RedactoPrivacyCenter/lib/types.ts +63 -2
  36. package/src/RedactoPrivacyCenter/locales/as/translation.json +9 -1
  37. package/src/RedactoPrivacyCenter/locales/bho/translation.json +9 -1
  38. package/src/RedactoPrivacyCenter/locales/bn/translation.json +9 -1
  39. package/src/RedactoPrivacyCenter/locales/brx/translation.json +9 -1
  40. package/src/RedactoPrivacyCenter/locales/doi/translation.json +9 -1
  41. package/src/RedactoPrivacyCenter/locales/en/translation.json +9 -1
  42. package/src/RedactoPrivacyCenter/locales/gom/translation.json +9 -1
  43. package/src/RedactoPrivacyCenter/locales/gu/translation.json +9 -1
  44. package/src/RedactoPrivacyCenter/locales/hi/translation.json +9 -1
  45. package/src/RedactoPrivacyCenter/locales/kn/translation.json +9 -1
  46. package/src/RedactoPrivacyCenter/locales/ks/translation.json +9 -1
  47. package/src/RedactoPrivacyCenter/locales/mai/translation.json +9 -1
  48. package/src/RedactoPrivacyCenter/locales/ml/translation.json +9 -1
  49. package/src/RedactoPrivacyCenter/locales/mni-Mtei/translation.json +9 -1
  50. package/src/RedactoPrivacyCenter/locales/mr/translation.json +9 -1
  51. package/src/RedactoPrivacyCenter/locales/ne/translation.json +9 -1
  52. package/src/RedactoPrivacyCenter/locales/or/translation.json +9 -1
  53. package/src/RedactoPrivacyCenter/locales/pa/translation.json +9 -1
  54. package/src/RedactoPrivacyCenter/locales/sa/translation.json +9 -1
  55. package/src/RedactoPrivacyCenter/locales/sat/translation.json +9 -1
  56. package/src/RedactoPrivacyCenter/locales/sd/translation.json +9 -1
  57. package/src/RedactoPrivacyCenter/locales/ta/translation.json +9 -1
  58. package/src/RedactoPrivacyCenter/locales/te/translation.json +9 -1
  59. package/src/RedactoPrivacyCenter/locales/ur/translation.json +9 -1
  60. package/src/RedactoPrivacyCenter/styles/injectStyles.ts +105 -0
  61. package/tests/Form.test.tsx +53 -7
  62. package/tests/ManageConsentErrorMapping.test.tsx +85 -0
  63. package/tests/RevocablePurpose.test.tsx +146 -0
  64. package/tests/RevokeWarningMessage.test.tsx +151 -0
  65. package/tests/consentClient.test.ts +171 -0
  66. package/tests/manageConsentServer.test.ts +38 -0
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
  import * as _tanstack_react_query from '@tanstack/react-query';
4
4
 
@@ -33,9 +33,12 @@ type BaseRequest = {
33
33
  * Creates a client instance with a specific base URL.
34
34
  * @param baseUrl - Consent server base URL (Python service, e.g. http://host/consent)
35
35
  * @param ledgerBaseUrl - Go ledger base URL (e.g. http://host:8090/consent-ledger).
36
- * Used for user-consents reads which are served from the ledger's `/public/...` paths.
36
+ * Used for user-consents reads/writes served from the ledger's `/public/...` paths.
37
+ * When omitted, those calls fall back to the legacy Python
38
+ * `/dsar/privacy-center` endpoints and payloads (pre-ledger behavior), so
39
+ * integrations without a deployed ledger keep working.
37
40
  */
38
- declare function createConsentClient(baseUrl: string, ledgerBaseUrl: string): {
41
+ declare function createConsentClient(baseUrl: string, ledgerBaseUrl?: string): {
39
42
  /**
40
43
  * Get form data (privacy center)
41
44
  */
@@ -96,14 +99,17 @@ declare function createConsentClient(baseUrl: string, ledgerBaseUrl: string): {
96
99
  /**
97
100
  * Manage consent (privacy center) - revoke, regrant, or renew.
98
101
  *
99
- * The Go ledger has no manage-consent route, so this is expressed as a
100
- * `partial` submit-consent on the ledger — mirroring the Python dual-write
101
- * relay (`build_consent_management_payload`): the affected purpose is
102
- * re-submitted with `selected: false` to revoke or `selected: true` to
103
- * regrant/renew, and `partial: true` so the rest of the notice's purposes
104
- * are left untouched. The principal is resolved from the JWT, so no
105
- * `contact`/identifiers are sent in the body, and `consent_event_uuid` is
106
- * omitted so the ledger mints a fresh event.
102
+ * The Go ledger has no manage-consent route, so with a ledger configured
103
+ * this is expressed as a `partial` submit-consent on the ledger — mirroring
104
+ * the Python dual-write relay (`build_consent_management_payload`): the
105
+ * affected purpose is re-submitted with `selected: false` to revoke or
106
+ * `selected: true` to regrant/renew, and `partial: true` so the rest of the
107
+ * notice's purposes are left untouched. The principal is resolved from the
108
+ * JWT, so no `contact`/identifiers are sent in the body, and
109
+ * `consent_event_uuid` is omitted so the ledger mints a fresh event.
110
+ *
111
+ * Without a ledger, the legacy Python `/manage-consent?status=` endpoint is
112
+ * used with its `{ purpose_uuid, contact, ... }` payload.
107
113
  */
108
114
  manageConsent(baseRequest: BaseRequest, purposeId: string, contact: string, status: "revoke" | "regrant" | "renew", authToken?: string, options?: Omit<ApiFetchOptions, "getAuthToken">, nominatorContact?: string, dataElementUuids?: string[], productUuid?: string, noticeUuid?: string, dataElements?: Array<{
109
115
  uuid: string;
@@ -113,6 +119,18 @@ declare function createConsentClient(baseUrl: string, ledgerBaseUrl: string): {
113
119
  * Get activities (privacy center)
114
120
  */
115
121
  getActivities(baseRequest: BaseRequest, offset?: number, limit?: number, language?: string, authToken?: string, options?: Omit<ApiFetchOptions, "getAuthToken">): Promise<unknown>;
122
+ /**
123
+ * List all data principals that share this session's contact
124
+ * (shared-contact profile picker). Identity is derived server-side from the
125
+ * JWT — the caller sends nothing but its bearer token.
126
+ */
127
+ listIdentities(baseRequest: BaseRequest, authToken?: string, options?: Omit<ApiFetchOptions, "getAuthToken">): Promise<IdentityListResponse>;
128
+ /**
129
+ * Re-scope the session to a chosen principal uuid (must be one of the
130
+ * principals sharing this session's contact). Returns fresh access/refresh
131
+ * tokens scoped to that principal.
132
+ */
133
+ selectPrincipal(baseRequest: BaseRequest, principalUuid: string, authToken?: string, options?: Omit<ApiFetchOptions, "getAuthToken">): Promise<SelectPrincipalResponse>;
116
134
  /**
117
135
  * Get receipts (privacy center) — consent receipts for the authenticated user
118
136
  */
@@ -372,6 +390,8 @@ type PurposeItem = {
372
390
  method: string;
373
391
  data_elements: ConsentDataElement[];
374
392
  link_reason: string | null;
393
+ revocable?: boolean;
394
+ revoke_warning_message?: string | null;
375
395
  notice_uuid: string | null;
376
396
  };
377
397
  type ConsentGroup = {
@@ -607,6 +627,21 @@ type NotificationQueryParams = {
607
627
  include_summary?: boolean;
608
628
  language?: string;
609
629
  };
630
+ type IdentityCandidate = Readonly<{
631
+ uuid: string;
632
+ org_user_id?: string | null;
633
+ primary_email?: string | null;
634
+ primary_mobile?: string | null;
635
+ created_at?: string | null;
636
+ }>;
637
+ type IdentityListResponse = Readonly<{
638
+ identities: IdentityCandidate[];
639
+ }>;
640
+ type SelectPrincipalResponse = Readonly<{
641
+ token: string;
642
+ refresh_token: string;
643
+ expires_at?: string;
644
+ }>;
610
645
 
611
646
  type InternalPage = 'consent-manager' | 'form' | 'activity' | 'case-details' | 'notifications' | 'receipts';
612
647
  interface NavigationContextType {
@@ -619,12 +654,12 @@ interface NavigationContextType {
619
654
  declare const NavigationProvider: ({ children, initialPage }: {
620
655
  children: ReactNode;
621
656
  initialPage?: InternalPage;
622
- }) => react_jsx_runtime.JSX.Element;
657
+ }) => react.JSX.Element;
623
658
  declare const useInternalNavigation: () => NavigationContextType;
624
659
 
625
660
  interface RedactoPrivacyCenterProps {
626
661
  baseUrl: string;
627
- ledgerBaseUrl: string;
662
+ ledgerBaseUrl?: string;
628
663
  slug: string;
629
664
  accessToken: string;
630
665
  refreshToken: string;
@@ -632,26 +667,26 @@ interface RedactoPrivacyCenterProps {
632
667
  initialPage?: InternalPage;
633
668
  onBack?: 'back' | 'signout';
634
669
  }
635
- declare function RedactoPrivacyCenter({ baseUrl, ledgerBaseUrl, slug, accessToken, refreshToken, onError, initialPage, onBack, }: RedactoPrivacyCenterProps): react_jsx_runtime.JSX.Element;
670
+ declare function RedactoPrivacyCenter({ baseUrl, ledgerBaseUrl, slug, accessToken, refreshToken, onError, initialPage, onBack, }: RedactoPrivacyCenterProps): react.JSX.Element;
636
671
 
637
672
  interface PrivacyCenterLayoutProps {
638
673
  children: ReactNode;
639
674
  slug: string;
640
675
  onBack?: 'back' | 'signout';
641
676
  }
642
- declare function PrivacyCenterLayout({ children, slug, onBack }: PrivacyCenterLayoutProps): react_jsx_runtime.JSX.Element;
677
+ declare function PrivacyCenterLayout({ children, slug, onBack }: PrivacyCenterLayoutProps): react.JSX.Element;
643
678
 
644
- declare function PrivacyCenterHomePage(): react_jsx_runtime.JSX.Element;
679
+ declare function PrivacyCenterHomePage(): react.JSX.Element;
645
680
 
646
- declare function PrivacyCenterConsentManagerPage(): react_jsx_runtime.JSX.Element;
681
+ declare function PrivacyCenterConsentManagerPage(): react.JSX.Element;
647
682
 
648
- declare function PrivacyCenterFormPage(): react_jsx_runtime.JSX.Element;
683
+ declare function PrivacyCenterFormPage(): react.JSX.Element;
649
684
 
650
- declare function PrivacyCenterActivityPage(): react_jsx_runtime.JSX.Element;
685
+ declare function PrivacyCenterActivityPage(): react.JSX.Element;
651
686
 
652
- declare const PrivacyCenterCaseDetailsPage: () => react_jsx_runtime.JSX.Element | null;
687
+ declare const PrivacyCenterCaseDetailsPage: () => react.JSX.Element | null;
653
688
 
654
- declare const NotificationsPage: () => react_jsx_runtime.JSX.Element;
689
+ declare const NotificationsPage: () => react.JSX.Element;
655
690
 
656
691
  type AuthContextValue = Readonly<{
657
692
  accessToken: string;
@@ -662,18 +697,18 @@ type AuthContextValue = Readonly<{
662
697
  }>;
663
698
  type BaseUrlContextValue = Readonly<{
664
699
  baseUrl: string;
665
- ledgerBaseUrl: string;
700
+ ledgerBaseUrl?: string;
666
701
  consentClient: ReturnType<typeof createConsentClient>;
667
702
  }>;
668
703
 
669
704
  declare const BaseUrlProvider: ({ children, baseUrl, ledgerBaseUrl, }: {
670
705
  children: ReactNode;
671
706
  baseUrl: string;
672
- ledgerBaseUrl: string;
673
- }) => react_jsx_runtime.JSX.Element;
707
+ ledgerBaseUrl?: string;
708
+ }) => react.JSX.Element;
674
709
  declare const useBaseUrl: () => Readonly<{
675
710
  baseUrl: string;
676
- ledgerBaseUrl: string;
711
+ ledgerBaseUrl?: string;
677
712
  consentClient: ReturnType<typeof createConsentClient>;
678
713
  }>;
679
714
 
@@ -840,7 +875,7 @@ declare const manageConsent: ({ organizationId, workspaceId, purposeId, contact,
840
875
  declare const fetchActivities: (organizationId: string, workspaceId: string, offset?: number, limit?: number, authContext?: AuthContext, consentClient?: BaseUrlContextValue["consentClient"], language?: string) => Promise<ActivityDetail | null>;
841
876
  declare const fetchCaseHistory: (organizationId: string, workspaceId: string, contact: string, offset?: number, limit?: number, authContext?: AuthContext, consentClient?: BaseUrlContextValue["consentClient"], language?: string) => Promise<CaseHistoryDetail | null>;
842
877
 
843
- declare const useCaseHistory: (organizationId: string | undefined, workspaceId: string | undefined, contact: string | undefined, authContext?: AuthContext) => _tanstack_react_query.UseQueryResult<CaseRequest[], Error>;
878
+ declare const useCaseHistory: (organizationId: string | undefined, workspaceId: string | undefined, contact: string | undefined, authContext?: AuthContext) => _tanstack_react_query.UseQueryResult<NoInfer<CaseRequest[]>, Error>;
844
879
 
845
880
  interface AuthProviderProps {
846
881
  children: ReactNode;
@@ -848,7 +883,7 @@ interface AuthProviderProps {
848
883
  refreshToken: string;
849
884
  onError: (error: Error) => boolean;
850
885
  }
851
- declare const AuthProvider: ({ children, accessToken: initialAccessToken, refreshToken: initialRefreshToken, onError, }: AuthProviderProps) => react_jsx_runtime.JSX.Element;
886
+ declare const AuthProvider: ({ children, accessToken: initialAccessToken, refreshToken: initialRefreshToken, onError, }: AuthProviderProps) => react.JSX.Element;
852
887
  declare const useAuth: () => AuthContextValue;
853
888
 
854
889
  /**