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

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 (84) hide show
  1. package/.turbo/turbo-build.log +11 -11
  2. package/CHANGELOG.md +109 -0
  3. package/README.md +78 -0
  4. package/dist/{chunk-6A665OPR.mjs → chunk-OGL6OC3A.mjs} +4 -0
  5. package/dist/index.d.mts +32 -4
  6. package/dist/index.d.ts +32 -4
  7. package/dist/index.js +340 -230
  8. package/dist/index.mjs +339 -231
  9. package/dist/privacy-center.d.mts +55 -12
  10. package/dist/privacy-center.d.ts +55 -12
  11. package/dist/privacy-center.js +848 -950
  12. package/dist/privacy-center.mjs +698 -802
  13. package/package.json +1 -1
  14. package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.test.tsx +87 -0
  15. package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.tsx +27 -0
  16. package/src/RedactoNoticeAssisted/api/index.ts +7 -1
  17. package/src/RedactoNoticeAssisted/api/types.ts +2 -0
  18. package/src/RedactoNoticeAssisted/i18n.ts +0 -55
  19. package/src/RedactoNoticeAssisted/types.ts +2 -0
  20. package/src/RedactoNoticeConsent/RedactoNoticeConsent.test.tsx +42 -8
  21. package/src/RedactoNoticeConsent/RedactoNoticeConsent.tsx +74 -33
  22. package/src/RedactoNoticeConsent/api/index.ts +88 -175
  23. package/src/RedactoNoticeConsent/api/sandbox.ts +150 -0
  24. package/src/RedactoNoticeConsent/api/types.ts +58 -43
  25. package/src/RedactoNoticeConsent/language-codes.ts +0 -2
  26. package/src/RedactoNoticeConsent/types.ts +28 -2
  27. package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.tsx +85 -5
  28. package/src/RedactoNoticeConsentInline/api/index.ts +10 -1
  29. package/src/RedactoNoticeConsentInline/api/notice-read-routing.test.ts +72 -0
  30. package/src/RedactoNoticeConsentInline/api/types.ts +2 -0
  31. package/src/RedactoPrivacyCenter/RedactoPrivacyCenter.tsx +37 -2
  32. package/src/RedactoPrivacyCenter/api/actions.ts +3 -1
  33. package/src/RedactoPrivacyCenter/api/client.ts +122 -25
  34. package/src/RedactoPrivacyCenter/api/fetcher.ts +24 -9
  35. package/src/RedactoPrivacyCenter/components/AppShell/AppShell.tsx +28 -0
  36. package/src/RedactoPrivacyCenter/components/AppShell/UserMenu.tsx +47 -45
  37. package/src/RedactoPrivacyCenter/components/ConsentManager.tsx +2 -1
  38. package/src/RedactoPrivacyCenter/components/Form.tsx +55 -30
  39. package/src/RedactoPrivacyCenter/components/ModifyConsentModal.tsx +1 -1
  40. package/src/RedactoPrivacyCenter/components/SelectUser.tsx +25 -13
  41. package/src/RedactoPrivacyCenter/components/SelectUserGate.tsx +8 -6
  42. package/src/RedactoPrivacyCenter/components/constant.ts +3 -3
  43. package/src/RedactoPrivacyCenter/components/groupHelpers.ts +42 -6
  44. package/src/RedactoPrivacyCenter/context/AuthContext.tsx +131 -39
  45. package/src/RedactoPrivacyCenter/context/types.ts +38 -0
  46. package/src/RedactoPrivacyCenter/lib/api.ts +3 -0
  47. package/src/RedactoPrivacyCenter/lib/constants.ts +12 -6
  48. package/src/RedactoPrivacyCenter/lib/locales.ts +0 -3
  49. package/src/RedactoPrivacyCenter/lib/sandbox.ts +104 -0
  50. package/src/RedactoPrivacyCenter/lib/types.ts +25 -1
  51. package/src/RedactoPrivacyCenter/lib/utils.ts +15 -0
  52. package/src/RedactoPrivacyCenter/locales/as/translation.json +3 -3
  53. package/src/RedactoPrivacyCenter/locales/bn/translation.json +3 -3
  54. package/src/RedactoPrivacyCenter/locales/brx/translation.json +3 -3
  55. package/src/RedactoPrivacyCenter/locales/doi/translation.json +3 -3
  56. package/src/RedactoPrivacyCenter/locales/en/translation.json +4 -3
  57. package/src/RedactoPrivacyCenter/locales/gom/translation.json +3 -3
  58. package/src/RedactoPrivacyCenter/locales/gu/translation.json +3 -3
  59. package/src/RedactoPrivacyCenter/locales/hi/translation.json +3 -3
  60. package/src/RedactoPrivacyCenter/locales/kn/translation.json +3 -3
  61. package/src/RedactoPrivacyCenter/locales/ks/translation.json +3 -3
  62. package/src/RedactoPrivacyCenter/locales/mai/translation.json +3 -3
  63. package/src/RedactoPrivacyCenter/locales/ml/translation.json +3 -3
  64. package/src/RedactoPrivacyCenter/locales/mni-Mtei/translation.json +3 -3
  65. package/src/RedactoPrivacyCenter/locales/mr/translation.json +3 -3
  66. package/src/RedactoPrivacyCenter/locales/ne/translation.json +3 -3
  67. package/src/RedactoPrivacyCenter/locales/or/translation.json +3 -3
  68. package/src/RedactoPrivacyCenter/locales/pa/translation.json +3 -3
  69. package/src/RedactoPrivacyCenter/locales/sa/translation.json +3 -3
  70. package/src/RedactoPrivacyCenter/locales/sat/translation.json +3 -3
  71. package/src/RedactoPrivacyCenter/locales/sd/translation.json +3 -3
  72. package/src/RedactoPrivacyCenter/locales/ta/translation.json +3 -3
  73. package/src/RedactoPrivacyCenter/locales/te/translation.json +3 -3
  74. package/src/RedactoPrivacyCenter/locales/ur/translation.json +3 -3
  75. package/src/RedactoPrivacyCenter/styles/injectStyles.ts +7 -2
  76. package/src/RedactoPrivacyCenter/styles/pcStyles.ts +17 -0
  77. package/src/RedactoPrivacyCenter/ui/PCAvatar.test.tsx +83 -0
  78. package/src/RedactoPrivacyCenter/ui/PCAvatar.tsx +33 -9
  79. package/src/shared/notice-consent-status.ts +190 -0
  80. package/src/shared/sandbox.ts +6 -0
  81. package/tests/Form.test.tsx +142 -5
  82. package/tests/RevokeWarningMessage.test.tsx +151 -0
  83. package/tests/consentClient.test.ts +46 -0
  84. package/src/RedactoPrivacyCenter/locales/bho/translation.json +0 -340
@@ -114,7 +114,7 @@ declare function createConsentClient(baseUrl: string, ledgerBaseUrl?: string): {
114
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<{
115
115
  uuid: string;
116
116
  selected: boolean;
117
- }>): Promise<unknown>;
117
+ }>, language?: string): Promise<unknown>;
118
118
  /**
119
119
  * Get activities (privacy center)
120
120
  */
@@ -382,6 +382,7 @@ type NominatorInfo = {
382
382
  };
383
383
  type PurposeItem = {
384
384
  purpose_uuid: string;
385
+ uuid?: string;
385
386
  name: string;
386
387
  description: string | null;
387
388
  status: ConsentStatusEnum | string;
@@ -390,6 +391,7 @@ type PurposeItem = {
390
391
  method: string;
391
392
  data_elements: ConsentDataElement[];
392
393
  link_reason: string | null;
394
+ revoke_warning_message?: string | null;
393
395
  notice_uuid: string | null;
394
396
  };
395
397
  type ConsentGroup = {
@@ -659,13 +661,36 @@ interface RedactoPrivacyCenterProps {
659
661
  baseUrl: string;
660
662
  ledgerBaseUrl?: string;
661
663
  slug: string;
662
- accessToken: string;
663
- refreshToken: string;
664
+ /** JWT access token. Optional so sandbox mode (see `token`) can omit it. */
665
+ accessToken?: string;
666
+ /** JWT refresh token. Optional; used by the OTP-refresh loop in the JWT flow. */
667
+ refreshToken?: string;
668
+ /**
669
+ * Sandbox PoC: a pasted static token. When set, the Privacy Center runs
670
+ * against the sandbox with no JWT — it sends the single `X-Consent-Token`
671
+ * header, carries the acting identity (`email` || `mobile`) in each request's
672
+ * own payload, takes org/workspace from `organisationUuid`/`workspaceUuid`,
673
+ * and never calls `/otp/refresh`.
674
+ */
675
+ token?: string;
676
+ /** Sandbox test subject email (carried in the request payload when set). */
677
+ email?: string;
678
+ /** Sandbox test subject mobile (fallback subject when `email` is absent). */
679
+ mobile?: string;
680
+ /**
681
+ * Sandbox UCIC: the client's own user id / org_user_id, e.g. a UUID or
682
+ * customer code; optional third identifier alongside email/mobile.
683
+ */
684
+ ucic?: string;
685
+ /** Sandbox org UUID (replaces the JWT-decoded org in sandbox mode). */
686
+ organisationUuid?: string;
687
+ /** Sandbox workspace UUID (replaces the JWT-decoded workspace in sandbox mode). */
688
+ workspaceUuid?: string;
664
689
  onError: (error: Error) => boolean;
665
690
  initialPage?: InternalPage;
666
691
  onBack?: 'back' | 'signout';
667
692
  }
668
- declare function RedactoPrivacyCenter({ baseUrl, ledgerBaseUrl, slug, accessToken, refreshToken, onError, initialPage, onBack, }: RedactoPrivacyCenterProps): react.JSX.Element;
693
+ declare function RedactoPrivacyCenter({ baseUrl, ledgerBaseUrl, slug, accessToken, refreshToken, token, email, mobile, ucic, organisationUuid, workspaceUuid, onError, initialPage, onBack, }: RedactoPrivacyCenterProps): react.JSX.Element;
669
694
 
670
695
  interface PrivacyCenterLayoutProps {
671
696
  children: ReactNode;
@@ -686,6 +711,29 @@ declare const PrivacyCenterCaseDetailsPage: () => react.JSX.Element | null;
686
711
 
687
712
  declare const NotificationsPage: () => react.JSX.Element;
688
713
 
714
+ type AuthProviderProps = Readonly<{
715
+ children: ReactNode;
716
+ accessToken?: string;
717
+ refreshToken?: string;
718
+ /**
719
+ * Sandbox PoC: when set, the Privacy Center skips the JWT entirely — it seeds
720
+ * org/workspace/subject from the props below, sends the single
721
+ * `X-Consent-Token` header, carries the acting identity in each request's own
722
+ * payload, and never calls `/otp/refresh`.
723
+ */
724
+ token?: string;
725
+ /** Sandbox UCIC — the client's own user id (`org_user_id`); takes precedence over the subject. */
726
+ sandboxUcic?: string;
727
+ /** Sandbox subject (email or mobile) — carried in the request payload. */
728
+ sandboxSubject?: string;
729
+ /** Sandbox org UUID (replaces the JWT-decoded org). */
730
+ organisationUuid?: string;
731
+ /** Sandbox workspace UUID (replaces the JWT-decoded workspace). */
732
+ workspaceUuid?: string;
733
+ /** Organisation slug — used to seed sandbox sessionStorage. */
734
+ slug?: string;
735
+ onError: (error: Error) => boolean;
736
+ }>;
689
737
  type AuthContextValue = Readonly<{
690
738
  accessToken: string;
691
739
  refreshToken: string;
@@ -853,7 +901,7 @@ type FetchGroupPurposesParams = {
853
901
  consentClient?: BaseUrlContextValue['consentClient'];
854
902
  };
855
903
  declare const fetchGroupPurposes: (params: FetchGroupPurposesParams) => Promise<GroupPurposesOut | null>;
856
- declare const manageConsent: ({ organizationId, workspaceId, purposeId, contact, action, authContext, consentClient, nominatorContact, dataElementUuids, productUuid, noticeUuid, dataElements, }: {
904
+ declare const manageConsent: ({ organizationId, workspaceId, purposeId, contact, action, authContext, consentClient, nominatorContact, dataElementUuids, productUuid, noticeUuid, dataElements, language, }: {
857
905
  organizationId: string;
858
906
  workspaceId: string;
859
907
  purposeId: string;
@@ -869,19 +917,14 @@ declare const manageConsent: ({ organizationId, workspaceId, purposeId, contact,
869
917
  uuid: string;
870
918
  selected: boolean;
871
919
  }>;
920
+ language?: string;
872
921
  }) => Promise<boolean | null>;
873
922
  declare const fetchActivities: (organizationId: string, workspaceId: string, offset?: number, limit?: number, authContext?: AuthContext, consentClient?: BaseUrlContextValue["consentClient"], language?: string) => Promise<ActivityDetail | null>;
874
923
  declare const fetchCaseHistory: (organizationId: string, workspaceId: string, contact: string, offset?: number, limit?: number, authContext?: AuthContext, consentClient?: BaseUrlContextValue["consentClient"], language?: string) => Promise<CaseHistoryDetail | null>;
875
924
 
876
925
  declare const useCaseHistory: (organizationId: string | undefined, workspaceId: string | undefined, contact: string | undefined, authContext?: AuthContext) => _tanstack_react_query.UseQueryResult<NoInfer<CaseRequest[]>, Error>;
877
926
 
878
- interface AuthProviderProps {
879
- children: ReactNode;
880
- accessToken: string;
881
- refreshToken: string;
882
- onError: (error: Error) => boolean;
883
- }
884
- declare const AuthProvider: ({ children, accessToken: initialAccessToken, refreshToken: initialRefreshToken, onError, }: AuthProviderProps) => react.JSX.Element;
927
+ declare const AuthProvider: (props: AuthProviderProps) => react.JSX.Element;
885
928
  declare const useAuth: () => AuthContextValue;
886
929
 
887
930
  /**
@@ -114,7 +114,7 @@ declare function createConsentClient(baseUrl: string, ledgerBaseUrl?: string): {
114
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<{
115
115
  uuid: string;
116
116
  selected: boolean;
117
- }>): Promise<unknown>;
117
+ }>, language?: string): Promise<unknown>;
118
118
  /**
119
119
  * Get activities (privacy center)
120
120
  */
@@ -382,6 +382,7 @@ type NominatorInfo = {
382
382
  };
383
383
  type PurposeItem = {
384
384
  purpose_uuid: string;
385
+ uuid?: string;
385
386
  name: string;
386
387
  description: string | null;
387
388
  status: ConsentStatusEnum | string;
@@ -390,6 +391,7 @@ type PurposeItem = {
390
391
  method: string;
391
392
  data_elements: ConsentDataElement[];
392
393
  link_reason: string | null;
394
+ revoke_warning_message?: string | null;
393
395
  notice_uuid: string | null;
394
396
  };
395
397
  type ConsentGroup = {
@@ -659,13 +661,36 @@ interface RedactoPrivacyCenterProps {
659
661
  baseUrl: string;
660
662
  ledgerBaseUrl?: string;
661
663
  slug: string;
662
- accessToken: string;
663
- refreshToken: string;
664
+ /** JWT access token. Optional so sandbox mode (see `token`) can omit it. */
665
+ accessToken?: string;
666
+ /** JWT refresh token. Optional; used by the OTP-refresh loop in the JWT flow. */
667
+ refreshToken?: string;
668
+ /**
669
+ * Sandbox PoC: a pasted static token. When set, the Privacy Center runs
670
+ * against the sandbox with no JWT — it sends the single `X-Consent-Token`
671
+ * header, carries the acting identity (`email` || `mobile`) in each request's
672
+ * own payload, takes org/workspace from `organisationUuid`/`workspaceUuid`,
673
+ * and never calls `/otp/refresh`.
674
+ */
675
+ token?: string;
676
+ /** Sandbox test subject email (carried in the request payload when set). */
677
+ email?: string;
678
+ /** Sandbox test subject mobile (fallback subject when `email` is absent). */
679
+ mobile?: string;
680
+ /**
681
+ * Sandbox UCIC: the client's own user id / org_user_id, e.g. a UUID or
682
+ * customer code; optional third identifier alongside email/mobile.
683
+ */
684
+ ucic?: string;
685
+ /** Sandbox org UUID (replaces the JWT-decoded org in sandbox mode). */
686
+ organisationUuid?: string;
687
+ /** Sandbox workspace UUID (replaces the JWT-decoded workspace in sandbox mode). */
688
+ workspaceUuid?: string;
664
689
  onError: (error: Error) => boolean;
665
690
  initialPage?: InternalPage;
666
691
  onBack?: 'back' | 'signout';
667
692
  }
668
- declare function RedactoPrivacyCenter({ baseUrl, ledgerBaseUrl, slug, accessToken, refreshToken, onError, initialPage, onBack, }: RedactoPrivacyCenterProps): react.JSX.Element;
693
+ declare function RedactoPrivacyCenter({ baseUrl, ledgerBaseUrl, slug, accessToken, refreshToken, token, email, mobile, ucic, organisationUuid, workspaceUuid, onError, initialPage, onBack, }: RedactoPrivacyCenterProps): react.JSX.Element;
669
694
 
670
695
  interface PrivacyCenterLayoutProps {
671
696
  children: ReactNode;
@@ -686,6 +711,29 @@ declare const PrivacyCenterCaseDetailsPage: () => react.JSX.Element | null;
686
711
 
687
712
  declare const NotificationsPage: () => react.JSX.Element;
688
713
 
714
+ type AuthProviderProps = Readonly<{
715
+ children: ReactNode;
716
+ accessToken?: string;
717
+ refreshToken?: string;
718
+ /**
719
+ * Sandbox PoC: when set, the Privacy Center skips the JWT entirely — it seeds
720
+ * org/workspace/subject from the props below, sends the single
721
+ * `X-Consent-Token` header, carries the acting identity in each request's own
722
+ * payload, and never calls `/otp/refresh`.
723
+ */
724
+ token?: string;
725
+ /** Sandbox UCIC — the client's own user id (`org_user_id`); takes precedence over the subject. */
726
+ sandboxUcic?: string;
727
+ /** Sandbox subject (email or mobile) — carried in the request payload. */
728
+ sandboxSubject?: string;
729
+ /** Sandbox org UUID (replaces the JWT-decoded org). */
730
+ organisationUuid?: string;
731
+ /** Sandbox workspace UUID (replaces the JWT-decoded workspace). */
732
+ workspaceUuid?: string;
733
+ /** Organisation slug — used to seed sandbox sessionStorage. */
734
+ slug?: string;
735
+ onError: (error: Error) => boolean;
736
+ }>;
689
737
  type AuthContextValue = Readonly<{
690
738
  accessToken: string;
691
739
  refreshToken: string;
@@ -853,7 +901,7 @@ type FetchGroupPurposesParams = {
853
901
  consentClient?: BaseUrlContextValue['consentClient'];
854
902
  };
855
903
  declare const fetchGroupPurposes: (params: FetchGroupPurposesParams) => Promise<GroupPurposesOut | null>;
856
- declare const manageConsent: ({ organizationId, workspaceId, purposeId, contact, action, authContext, consentClient, nominatorContact, dataElementUuids, productUuid, noticeUuid, dataElements, }: {
904
+ declare const manageConsent: ({ organizationId, workspaceId, purposeId, contact, action, authContext, consentClient, nominatorContact, dataElementUuids, productUuid, noticeUuid, dataElements, language, }: {
857
905
  organizationId: string;
858
906
  workspaceId: string;
859
907
  purposeId: string;
@@ -869,19 +917,14 @@ declare const manageConsent: ({ organizationId, workspaceId, purposeId, contact,
869
917
  uuid: string;
870
918
  selected: boolean;
871
919
  }>;
920
+ language?: string;
872
921
  }) => Promise<boolean | null>;
873
922
  declare const fetchActivities: (organizationId: string, workspaceId: string, offset?: number, limit?: number, authContext?: AuthContext, consentClient?: BaseUrlContextValue["consentClient"], language?: string) => Promise<ActivityDetail | null>;
874
923
  declare const fetchCaseHistory: (organizationId: string, workspaceId: string, contact: string, offset?: number, limit?: number, authContext?: AuthContext, consentClient?: BaseUrlContextValue["consentClient"], language?: string) => Promise<CaseHistoryDetail | null>;
875
924
 
876
925
  declare const useCaseHistory: (organizationId: string | undefined, workspaceId: string | undefined, contact: string | undefined, authContext?: AuthContext) => _tanstack_react_query.UseQueryResult<NoInfer<CaseRequest[]>, Error>;
877
926
 
878
- interface AuthProviderProps {
879
- children: ReactNode;
880
- accessToken: string;
881
- refreshToken: string;
882
- onError: (error: Error) => boolean;
883
- }
884
- declare const AuthProvider: ({ children, accessToken: initialAccessToken, refreshToken: initialRefreshToken, onError, }: AuthProviderProps) => react.JSX.Element;
927
+ declare const AuthProvider: (props: AuthProviderProps) => react.JSX.Element;
885
928
  declare const useAuth: () => AuthContextValue;
886
929
 
887
930
  /**