@redacto.io/consent-sdk-react 3.2.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +11 -0
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +423 -136
- package/dist/index.mjs +423 -136
- package/package.json +1 -1
- package/src/RedactoNoticeConsent/RedactoNoticeConsent.test.tsx +123 -1
- package/src/RedactoNoticeConsent/RedactoNoticeConsent.tsx +936 -671
- package/src/RedactoNoticeConsent/api/index.ts +67 -53
- package/src/RedactoNoticeConsent/api/types.ts +67 -13
- package/src/RedactoNoticeConsent/constants.ts +20 -0
- package/src/RedactoNoticeConsent/styles.ts +3 -6
- package/src/RedactoNoticeConsent/types.ts +11 -5
- package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.tsx +30 -26
- package/src/RedactoNoticeConsentInline/api/index.ts +65 -27
- package/src/RedactoNoticeConsentInline/api/types.ts +28 -11
- package/src/RedactoNoticeConsentInline/types.ts +9 -4
- package/src/types/react-jsx.d.ts +26 -0
- package/src/utils/isLegacyApi.ts +12 -0
- package/tests/mocks.ts +53 -7
- package/tsconfig.json +1 -5
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { DpoInfo, DpoInfoTranslation } from "../../RedactoNoticeConsent/api/types";
|
|
2
|
+
|
|
1
3
|
export type RedactoJwtPayload = {
|
|
2
4
|
organisation_uuid: string;
|
|
3
5
|
workspace_uuid: string;
|
|
@@ -33,7 +35,7 @@ export type ConsentContent = {
|
|
|
33
35
|
decline_button_text: string;
|
|
34
36
|
logo_url: string;
|
|
35
37
|
privacy_policy_url: string;
|
|
36
|
-
|
|
38
|
+
privacy_center_url: string;
|
|
37
39
|
primary_color: string;
|
|
38
40
|
secondary_color: string;
|
|
39
41
|
font_preference: string;
|
|
@@ -59,26 +61,26 @@ export type ConsentContent = {
|
|
|
59
61
|
confirm_button_text: string;
|
|
60
62
|
decline_button_text: string;
|
|
61
63
|
privacy_policy_prefix_text: string;
|
|
62
|
-
vendor_list_prefix_text: string;
|
|
63
64
|
privacy_policy_anchor_text: string;
|
|
64
|
-
|
|
65
|
+
privacy_center_anchor_text?: string;
|
|
65
66
|
purpose_section_heading: string;
|
|
66
67
|
data_elements: {
|
|
67
68
|
[key: string]: string;
|
|
68
69
|
};
|
|
69
70
|
purposes: {
|
|
70
|
-
[key: string]: string;
|
|
71
|
+
[key: string]: string | { name: string; description: string };
|
|
71
72
|
};
|
|
73
|
+
dpo_info?: DpoInfoTranslation;
|
|
72
74
|
};
|
|
73
75
|
};
|
|
74
76
|
created_at: string;
|
|
75
77
|
updated_at: string;
|
|
76
78
|
deployed_at: string;
|
|
77
79
|
privacy_policy_prefix_text: string;
|
|
78
|
-
vendor_list_prefix_text: string;
|
|
79
80
|
privacy_policy_anchor_text: string;
|
|
80
|
-
|
|
81
|
+
privacy_center_anchor_text?: string;
|
|
81
82
|
purpose_section_heading: string;
|
|
83
|
+
dpo_info?: DpoInfo;
|
|
82
84
|
};
|
|
83
85
|
created_at: string;
|
|
84
86
|
updated_at: string;
|
|
@@ -132,9 +134,26 @@ export type FetchConsentContentParams = {
|
|
|
132
134
|
};
|
|
133
135
|
|
|
134
136
|
export type ConsentEventPayload = {
|
|
135
|
-
|
|
137
|
+
notice_uuid: string;
|
|
138
|
+
purposes: Array<{
|
|
139
|
+
purpose_uuid: string;
|
|
140
|
+
selected: boolean;
|
|
141
|
+
data_elements?: Array<{
|
|
142
|
+
uuid: string;
|
|
143
|
+
selected: boolean;
|
|
144
|
+
}>;
|
|
145
|
+
}>;
|
|
146
|
+
select_all_mandatory: boolean;
|
|
147
|
+
source?: string;
|
|
148
|
+
declined?: boolean;
|
|
149
|
+
meta_data?: {
|
|
150
|
+
specific_uuid: string;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// @deprecated Remove when production backend supports the new payload format.
|
|
155
|
+
export type LegacyConsentEventPayload = {
|
|
136
156
|
primary_email?: string;
|
|
137
|
-
primary_mobile?: string;
|
|
138
157
|
notice_uuid: string;
|
|
139
158
|
source: string;
|
|
140
159
|
declined: boolean;
|
|
@@ -154,9 +173,7 @@ export type ConsentEventPayload = {
|
|
|
154
173
|
}>;
|
|
155
174
|
}>;
|
|
156
175
|
};
|
|
157
|
-
meta_data?: {
|
|
158
|
-
specific_uuid: string;
|
|
159
|
-
};
|
|
176
|
+
meta_data?: { specific_uuid: string };
|
|
160
177
|
};
|
|
161
178
|
|
|
162
179
|
export type DataElement = {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Settings } from "./api/types";
|
|
2
|
+
import type { DpoInfoTranslation } from "../RedactoNoticeConsent/api/types";
|
|
2
3
|
|
|
3
4
|
export type Props = Readonly<{
|
|
4
5
|
org_uuid: string;
|
|
@@ -16,8 +17,10 @@ export type Props = Readonly<{
|
|
|
16
17
|
applicationId?: string;
|
|
17
18
|
}>;
|
|
18
19
|
|
|
20
|
+
export type PurposeTranslation = string | { name: string; description: string };
|
|
21
|
+
|
|
19
22
|
export type PurposeTranslations = {
|
|
20
|
-
[purposeId: string]:
|
|
23
|
+
[purposeId: string]: PurposeTranslation;
|
|
21
24
|
};
|
|
22
25
|
|
|
23
26
|
export type DataElementTranslations = {
|
|
@@ -33,13 +36,15 @@ export type TranslationObject = {
|
|
|
33
36
|
data_elements?: DataElementTranslations;
|
|
34
37
|
purpose_section_heading?: string;
|
|
35
38
|
privacy_policy_prefix_text?: string;
|
|
36
|
-
vendor_list_prefix_text?: string;
|
|
37
39
|
privacy_policy_anchor_text?: string;
|
|
38
|
-
|
|
40
|
+
privacy_center_anchor_text?: string;
|
|
41
|
+
dpo_info?: DpoInfoTranslation;
|
|
39
42
|
[key: string]:
|
|
40
43
|
| string
|
|
41
44
|
| PurposeTranslations
|
|
42
45
|
| DataElementTranslations
|
|
43
|
-
|
|
|
46
|
+
| DpoInfoTranslation
|
|
47
|
+
| Record<string, string | undefined>
|
|
48
|
+
| Record<string, string | { name: string; description: string }>
|
|
44
49
|
| undefined;
|
|
45
50
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React 19 JSX compatibility: ensures intrinsic elements (div, button, etc.)
|
|
3
|
+
* and Element type align with React's types to fix "Element is not assignable to ReactNode".
|
|
4
|
+
* @see https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/71395
|
|
5
|
+
*/
|
|
6
|
+
import type React from "react";
|
|
7
|
+
|
|
8
|
+
declare global {
|
|
9
|
+
namespace JSX {
|
|
10
|
+
type Element = React.ReactElement;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module "react/jsx-runtime" {
|
|
15
|
+
namespace JSX {
|
|
16
|
+
type Element = React.ReactElement;
|
|
17
|
+
interface IntrinsicElements extends React.JSX.IntrinsicElements {}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare module "react/jsx-dev-runtime" {
|
|
22
|
+
namespace JSX {
|
|
23
|
+
type Element = React.ReactElement;
|
|
24
|
+
interface IntrinsicElements extends React.JSX.IntrinsicElements {}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// @deprecated Remove when production backend supports the new payload format.
|
|
2
|
+
export function isLegacyApi(baseUrl: string): boolean {
|
|
3
|
+
try {
|
|
4
|
+
return new URL(baseUrl).hostname.endsWith(".redacto.io");
|
|
5
|
+
} catch {
|
|
6
|
+
try {
|
|
7
|
+
return new URL(`https://${baseUrl}`).hostname.endsWith(".redacto.io");
|
|
8
|
+
} catch {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
package/tests/mocks.ts
CHANGED
|
@@ -24,16 +24,28 @@ export const mockConsentContent: ConsentContent = {
|
|
|
24
24
|
decline_button_text: "Decline",
|
|
25
25
|
logo_url: "https://example.com/logo.png",
|
|
26
26
|
privacy_policy_url: "https://example.com/privacy",
|
|
27
|
-
|
|
27
|
+
privacy_center_url: "https://example.com/privacy-center",
|
|
28
28
|
primary_color: "#4f87ff",
|
|
29
29
|
secondary_color: "#ffffff",
|
|
30
30
|
font_preference: "Arial",
|
|
31
31
|
privacy_policy_prefix_text: "",
|
|
32
|
-
vendor_list_prefix_text: "",
|
|
33
32
|
privacy_policy_anchor_text: "Privacy Policy",
|
|
34
|
-
|
|
33
|
+
privacy_center_anchor_text: "Privacy Center",
|
|
35
34
|
purpose_section_heading: "Manage Consent",
|
|
36
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
|
+
},
|
|
37
49
|
created_at: "2023-01-01T00:00:00Z",
|
|
38
50
|
updated_at: "2023-01-01T00:00:00Z",
|
|
39
51
|
deployed_at: "2023-01-01T00:00:00Z",
|
|
@@ -42,21 +54,28 @@ export const mockConsentContent: ConsentContent = {
|
|
|
42
54
|
notice_text: "Nos importa tu privacidad.",
|
|
43
55
|
additional_text: "",
|
|
44
56
|
privacy_policy_prefix_text: "",
|
|
45
|
-
vendor_list_prefix_text: "",
|
|
46
57
|
privacy_policy_anchor_text: "Política de Privacidad",
|
|
47
|
-
vendors_list_anchor_text: "Lista de Proveedores",
|
|
48
58
|
confirm_button_text: "Aceptar",
|
|
49
59
|
decline_button_text: "Rechazar",
|
|
50
60
|
purpose_section_heading: "Gestionar Consentimiento",
|
|
51
61
|
notice_banner_heading: "Aviso de Privacidad",
|
|
62
|
+
privacy_center_anchor_text: "Centro de Privacidad",
|
|
52
63
|
purposes: {
|
|
53
|
-
"purpose-1": "Marketing",
|
|
54
|
-
"purpose-1-description": "Usamos datos para marketing.",
|
|
64
|
+
"purpose-1": { name: "Marketing", description: "Usamos datos para marketing." },
|
|
55
65
|
},
|
|
56
66
|
data_elements: {
|
|
57
67
|
"element-1": "Email",
|
|
58
68
|
"element-2": "Phone",
|
|
59
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
|
+
},
|
|
60
79
|
},
|
|
61
80
|
},
|
|
62
81
|
purposes: [
|
|
@@ -176,6 +195,33 @@ export const mockReconsentContent: ConsentContent = {
|
|
|
176
195
|
},
|
|
177
196
|
} as const;
|
|
178
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
|
+
|
|
179
225
|
export const mockMinorConsentContent: ConsentContent = {
|
|
180
226
|
...mockConsentContent,
|
|
181
227
|
detail: {
|
package/tsconfig.json
CHANGED