@redacto.io/consent-sdk-react 3.4.0 → 3.5.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @redacto.io/consent-sdk-react
2
2
 
3
+ ## 3.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - add legacy api
8
+
3
9
  ## 3.4.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.js CHANGED
@@ -30,21 +30,6 @@ var import_react2 = require("react");
30
30
 
31
31
  // src/RedactoNoticeConsent/api/index.ts
32
32
  var import_jwt_decode = require("jwt-decode");
33
-
34
- // src/utils/isLegacyApi.ts
35
- function isLegacyApi(baseUrl) {
36
- try {
37
- return new URL(baseUrl).hostname.endsWith(".redacto.io");
38
- } catch {
39
- try {
40
- return new URL(`https://${baseUrl}`).hostname.endsWith(".redacto.io");
41
- } catch {
42
- return false;
43
- }
44
- }
45
- }
46
-
47
- // src/RedactoNoticeConsent/api/index.ts
48
33
  var BASE_URL = "https://api.redacto.io/consent";
49
34
  var apiCache = /* @__PURE__ */ new Map();
50
35
  var CACHE_TTL = 5 * 60 * 1e3;
@@ -172,61 +157,28 @@ var submitConsentEvent = async ({
172
157
  throw new Error("Invalid token: missing organization or workspace UUID");
173
158
  }
174
159
  const apiBaseUrl = baseUrl || BASE_URL;
175
- let payload;
176
- if (isLegacyApi(apiBaseUrl)) {
177
- const primaryEmail = typeof window !== "undefined" ? localStorage.getItem("userEmail") : null;
178
- payload = {
179
- primary_email: primaryEmail || void 0,
180
- notice_uuid: noticeUuid,
181
- source: "WEB",
182
- declined: Boolean(declined),
183
- consents: {
184
- purposes: purposes.map((purpose) => {
185
- if (!purpose.uuid) {
186
- throw new Error(`Invalid purpose data: missing uuid`);
187
- }
188
- return {
189
- uuid: purpose.uuid,
190
- name: purpose.name,
191
- description: purpose.description || "",
192
- industries: purpose.industries || "",
193
- selected: Boolean(purpose.selected),
194
- data_elements: (purpose.data_elements || []).map((element) => ({
195
- uuid: element.uuid,
196
- name: element.name,
197
- enabled: Boolean(element.enabled),
198
- required: Boolean(element.required),
199
- selected: element.required ? true : Boolean(element.selected)
200
- }))
201
- };
202
- })
203
- },
204
- meta_data: meta_data ? { specific_uuid: meta_data.specific_uuid } : void 0
205
- };
206
- } else {
207
- const validatedPurposes = purposes.map((purpose) => {
208
- if (!purpose.uuid) {
209
- throw new Error(`Invalid purpose data: missing uuid`);
210
- }
211
- const dataElements = (purpose.data_elements || []).filter((element) => element.enabled).map((element) => ({
212
- uuid: element.uuid,
213
- selected: element.required ? true : Boolean(element.selected)
214
- }));
215
- return {
216
- purpose_uuid: purpose.uuid,
217
- selected: Boolean(purpose.selected),
218
- data_elements: dataElements.length > 0 ? dataElements : void 0
219
- };
220
- });
221
- payload = {
222
- notice_uuid: noticeUuid,
223
- purposes: validatedPurposes,
224
- select_all_mandatory: false,
225
- source: "WEB",
226
- declined: Boolean(declined),
227
- meta_data: meta_data ? { specific_uuid: meta_data.specific_uuid } : void 0
160
+ const validatedPurposes = purposes.map((purpose) => {
161
+ if (!purpose.uuid) {
162
+ throw new Error(`Invalid purpose data: missing uuid`);
163
+ }
164
+ const dataElements = (purpose.data_elements || []).filter((element) => element.enabled).map((element) => ({
165
+ uuid: element.uuid,
166
+ selected: element.required ? true : Boolean(element.selected)
167
+ }));
168
+ return {
169
+ purpose_uuid: purpose.uuid,
170
+ selected: Boolean(purpose.selected),
171
+ data_elements: dataElements.length > 0 ? dataElements : void 0
228
172
  };
229
- }
173
+ });
174
+ const payload = {
175
+ notice_uuid: noticeUuid,
176
+ purposes: validatedPurposes,
177
+ select_all_mandatory: false,
178
+ source: "WEB",
179
+ declined: Boolean(declined),
180
+ meta_data: meta_data ? { specific_uuid: meta_data.specific_uuid } : void 0
181
+ };
230
182
  const response = await fetch(
231
183
  `${apiBaseUrl}/public/organisations/${ORGANISATION_UUID}/workspaces/${WORKSPACE_UUID}/submit-consent`,
232
184
  {
@@ -3501,60 +3453,27 @@ var submitConsentEvent2 = async ({
3501
3453
  var _a, _b;
3502
3454
  try {
3503
3455
  const apiBaseUrl = baseUrl || BASE_URL2;
3504
- let payload;
3505
- if (isLegacyApi(apiBaseUrl)) {
3506
- const primaryEmail = typeof window !== "undefined" ? localStorage.getItem("userEmail") : null;
3507
- payload = {
3508
- primary_email: primaryEmail || void 0,
3509
- notice_uuid: noticeUuid,
3510
- source: "WEB",
3511
- declined: Boolean(declined),
3512
- consents: {
3513
- purposes: purposes.map((purpose) => {
3514
- if (!purpose.uuid) {
3515
- throw new Error(`Invalid purpose data: missing uuid`);
3516
- }
3517
- return {
3518
- uuid: purpose.uuid,
3519
- name: purpose.name,
3520
- description: purpose.description || "",
3521
- industries: purpose.industries || "",
3522
- selected: Boolean(purpose.selected),
3523
- data_elements: (purpose.data_elements || []).map((element) => ({
3524
- uuid: element.uuid,
3525
- name: element.name,
3526
- enabled: Boolean(element.enabled),
3527
- required: Boolean(element.required),
3528
- selected: element.required ? true : Boolean(element.selected)
3529
- }))
3530
- };
3531
- })
3532
- },
3533
- meta_data: meta_data ? { specific_uuid: meta_data.specific_uuid } : void 0
3534
- };
3535
- } else {
3536
- payload = {
3537
- notice_uuid: noticeUuid,
3538
- purposes: purposes.map((purpose) => {
3539
- if (!purpose.uuid) {
3540
- throw new Error(`Invalid purpose data: missing uuid`);
3541
- }
3542
- const dataElements = purpose.data_elements.filter((element) => element.enabled).map((element) => ({
3543
- uuid: element.uuid,
3544
- selected: element.required ? true : Boolean(element.selected)
3545
- }));
3546
- return {
3547
- purpose_uuid: purpose.uuid,
3548
- selected: Boolean(purpose.selected),
3549
- data_elements: dataElements.length > 0 ? dataElements : void 0
3550
- };
3551
- }),
3552
- select_all_mandatory: false,
3553
- source: "WEB",
3554
- declined,
3555
- meta_data
3556
- };
3557
- }
3456
+ const payload = {
3457
+ notice_uuid: noticeUuid,
3458
+ purposes: purposes.map((purpose) => {
3459
+ if (!purpose.uuid) {
3460
+ throw new Error(`Invalid purpose data: missing uuid`);
3461
+ }
3462
+ const dataElements = purpose.data_elements.filter((element) => element.enabled).map((element) => ({
3463
+ uuid: element.uuid,
3464
+ selected: element.required ? true : Boolean(element.selected)
3465
+ }));
3466
+ return {
3467
+ purpose_uuid: purpose.uuid,
3468
+ selected: Boolean(purpose.selected),
3469
+ data_elements: dataElements.length > 0 ? dataElements : void 0
3470
+ };
3471
+ }),
3472
+ select_all_mandatory: false,
3473
+ source: "WEB",
3474
+ declined,
3475
+ meta_data
3476
+ };
3558
3477
  const response = await fetch(
3559
3478
  `${apiBaseUrl}/public/organisations/${org_uuid}/workspaces/${workspace_uuid}/submit-consent`,
3560
3479
  {
package/dist/index.mjs CHANGED
@@ -3,21 +3,6 @@ import { useCallback, useEffect as useEffect2, useMemo, useRef, useState as useS
3
3
 
4
4
  // src/RedactoNoticeConsent/api/index.ts
5
5
  import { jwtDecode } from "jwt-decode";
6
-
7
- // src/utils/isLegacyApi.ts
8
- function isLegacyApi(baseUrl) {
9
- try {
10
- return new URL(baseUrl).hostname.endsWith(".redacto.io");
11
- } catch {
12
- try {
13
- return new URL(`https://${baseUrl}`).hostname.endsWith(".redacto.io");
14
- } catch {
15
- return false;
16
- }
17
- }
18
- }
19
-
20
- // src/RedactoNoticeConsent/api/index.ts
21
6
  var BASE_URL = "https://api.redacto.io/consent";
22
7
  var apiCache = /* @__PURE__ */ new Map();
23
8
  var CACHE_TTL = 5 * 60 * 1e3;
@@ -145,61 +130,28 @@ var submitConsentEvent = async ({
145
130
  throw new Error("Invalid token: missing organization or workspace UUID");
146
131
  }
147
132
  const apiBaseUrl = baseUrl || BASE_URL;
148
- let payload;
149
- if (isLegacyApi(apiBaseUrl)) {
150
- const primaryEmail = typeof window !== "undefined" ? localStorage.getItem("userEmail") : null;
151
- payload = {
152
- primary_email: primaryEmail || void 0,
153
- notice_uuid: noticeUuid,
154
- source: "WEB",
155
- declined: Boolean(declined),
156
- consents: {
157
- purposes: purposes.map((purpose) => {
158
- if (!purpose.uuid) {
159
- throw new Error(`Invalid purpose data: missing uuid`);
160
- }
161
- return {
162
- uuid: purpose.uuid,
163
- name: purpose.name,
164
- description: purpose.description || "",
165
- industries: purpose.industries || "",
166
- selected: Boolean(purpose.selected),
167
- data_elements: (purpose.data_elements || []).map((element) => ({
168
- uuid: element.uuid,
169
- name: element.name,
170
- enabled: Boolean(element.enabled),
171
- required: Boolean(element.required),
172
- selected: element.required ? true : Boolean(element.selected)
173
- }))
174
- };
175
- })
176
- },
177
- meta_data: meta_data ? { specific_uuid: meta_data.specific_uuid } : void 0
178
- };
179
- } else {
180
- const validatedPurposes = purposes.map((purpose) => {
181
- if (!purpose.uuid) {
182
- throw new Error(`Invalid purpose data: missing uuid`);
183
- }
184
- const dataElements = (purpose.data_elements || []).filter((element) => element.enabled).map((element) => ({
185
- uuid: element.uuid,
186
- selected: element.required ? true : Boolean(element.selected)
187
- }));
188
- return {
189
- purpose_uuid: purpose.uuid,
190
- selected: Boolean(purpose.selected),
191
- data_elements: dataElements.length > 0 ? dataElements : void 0
192
- };
193
- });
194
- payload = {
195
- notice_uuid: noticeUuid,
196
- purposes: validatedPurposes,
197
- select_all_mandatory: false,
198
- source: "WEB",
199
- declined: Boolean(declined),
200
- meta_data: meta_data ? { specific_uuid: meta_data.specific_uuid } : void 0
133
+ const validatedPurposes = purposes.map((purpose) => {
134
+ if (!purpose.uuid) {
135
+ throw new Error(`Invalid purpose data: missing uuid`);
136
+ }
137
+ const dataElements = (purpose.data_elements || []).filter((element) => element.enabled).map((element) => ({
138
+ uuid: element.uuid,
139
+ selected: element.required ? true : Boolean(element.selected)
140
+ }));
141
+ return {
142
+ purpose_uuid: purpose.uuid,
143
+ selected: Boolean(purpose.selected),
144
+ data_elements: dataElements.length > 0 ? dataElements : void 0
201
145
  };
202
- }
146
+ });
147
+ const payload = {
148
+ notice_uuid: noticeUuid,
149
+ purposes: validatedPurposes,
150
+ select_all_mandatory: false,
151
+ source: "WEB",
152
+ declined: Boolean(declined),
153
+ meta_data: meta_data ? { specific_uuid: meta_data.specific_uuid } : void 0
154
+ };
203
155
  const response = await fetch(
204
156
  `${apiBaseUrl}/public/organisations/${ORGANISATION_UUID}/workspaces/${WORKSPACE_UUID}/submit-consent`,
205
157
  {
@@ -3474,60 +3426,27 @@ var submitConsentEvent2 = async ({
3474
3426
  var _a, _b;
3475
3427
  try {
3476
3428
  const apiBaseUrl = baseUrl || BASE_URL2;
3477
- let payload;
3478
- if (isLegacyApi(apiBaseUrl)) {
3479
- const primaryEmail = typeof window !== "undefined" ? localStorage.getItem("userEmail") : null;
3480
- payload = {
3481
- primary_email: primaryEmail || void 0,
3482
- notice_uuid: noticeUuid,
3483
- source: "WEB",
3484
- declined: Boolean(declined),
3485
- consents: {
3486
- purposes: purposes.map((purpose) => {
3487
- if (!purpose.uuid) {
3488
- throw new Error(`Invalid purpose data: missing uuid`);
3489
- }
3490
- return {
3491
- uuid: purpose.uuid,
3492
- name: purpose.name,
3493
- description: purpose.description || "",
3494
- industries: purpose.industries || "",
3495
- selected: Boolean(purpose.selected),
3496
- data_elements: (purpose.data_elements || []).map((element) => ({
3497
- uuid: element.uuid,
3498
- name: element.name,
3499
- enabled: Boolean(element.enabled),
3500
- required: Boolean(element.required),
3501
- selected: element.required ? true : Boolean(element.selected)
3502
- }))
3503
- };
3504
- })
3505
- },
3506
- meta_data: meta_data ? { specific_uuid: meta_data.specific_uuid } : void 0
3507
- };
3508
- } else {
3509
- payload = {
3510
- notice_uuid: noticeUuid,
3511
- purposes: purposes.map((purpose) => {
3512
- if (!purpose.uuid) {
3513
- throw new Error(`Invalid purpose data: missing uuid`);
3514
- }
3515
- const dataElements = purpose.data_elements.filter((element) => element.enabled).map((element) => ({
3516
- uuid: element.uuid,
3517
- selected: element.required ? true : Boolean(element.selected)
3518
- }));
3519
- return {
3520
- purpose_uuid: purpose.uuid,
3521
- selected: Boolean(purpose.selected),
3522
- data_elements: dataElements.length > 0 ? dataElements : void 0
3523
- };
3524
- }),
3525
- select_all_mandatory: false,
3526
- source: "WEB",
3527
- declined,
3528
- meta_data
3529
- };
3530
- }
3429
+ const payload = {
3430
+ notice_uuid: noticeUuid,
3431
+ purposes: purposes.map((purpose) => {
3432
+ if (!purpose.uuid) {
3433
+ throw new Error(`Invalid purpose data: missing uuid`);
3434
+ }
3435
+ const dataElements = purpose.data_elements.filter((element) => element.enabled).map((element) => ({
3436
+ uuid: element.uuid,
3437
+ selected: element.required ? true : Boolean(element.selected)
3438
+ }));
3439
+ return {
3440
+ purpose_uuid: purpose.uuid,
3441
+ selected: Boolean(purpose.selected),
3442
+ data_elements: dataElements.length > 0 ? dataElements : void 0
3443
+ };
3444
+ }),
3445
+ select_all_mandatory: false,
3446
+ source: "WEB",
3447
+ declined,
3448
+ meta_data
3449
+ };
3531
3450
  const response = await fetch(
3532
3451
  `${apiBaseUrl}/public/organisations/${org_uuid}/workspaces/${workspace_uuid}/submit-consent`,
3533
3452
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redacto.io/consent-sdk-react",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -5,13 +5,11 @@ import type {
5
5
  FetchConsentContentParams,
6
6
  FetchTTSAudioUrlsParams,
7
7
  GuardianInfoPayload,
8
- LegacyConsentEventPayload,
9
8
  RedactoJwtPayload,
10
9
  SubmitConsentEventParams,
11
10
  SubmitGuardianInfoParams,
12
11
  TTSAudioUrlsResponse,
13
12
  } from "./types";
14
- import { isLegacyApi } from "../../utils/isLegacyApi";
15
13
 
16
14
  const BASE_URL = "https://api.redacto.io/consent";
17
15
 
@@ -173,70 +171,34 @@ export const submitConsentEvent = async ({
173
171
 
174
172
  const apiBaseUrl = baseUrl || BASE_URL;
175
173
 
176
- let payload: ConsentEventPayload | LegacyConsentEventPayload;
177
-
178
- if (isLegacyApi(apiBaseUrl)) {
179
- // @deprecated Legacy payload for production (.io) backend
180
- const primaryEmail = typeof window !== "undefined" ? localStorage.getItem("userEmail") : null;
181
- payload = {
182
- primary_email: primaryEmail || undefined,
183
- notice_uuid: noticeUuid,
184
- source: "WEB",
185
- declined: Boolean(declined),
186
- consents: {
187
- purposes: purposes.map((purpose) => {
188
- if (!purpose.uuid) {
189
- throw new Error(`Invalid purpose data: missing uuid`);
190
- }
191
- return {
192
- uuid: purpose.uuid,
193
- name: purpose.name,
194
- description: purpose.description || "",
195
- industries: purpose.industries || "",
196
- selected: Boolean(purpose.selected),
197
- data_elements: (purpose.data_elements || []).map((element) => ({
198
- uuid: element.uuid,
199
- name: element.name,
200
- enabled: Boolean(element.enabled),
201
- required: Boolean(element.required),
202
- selected: element.required ? true : Boolean(element.selected),
203
- })),
204
- };
205
- }),
206
- },
207
- meta_data: meta_data ? { specific_uuid: meta_data.specific_uuid } : undefined,
208
- };
209
- } else {
210
- // New payload for staging (.tech) / localhost
211
- const validatedPurposes = purposes.map((purpose) => {
212
- if (!purpose.uuid) {
213
- throw new Error(`Invalid purpose data: missing uuid`);
214
- }
174
+ const validatedPurposes = purposes.map((purpose) => {
175
+ if (!purpose.uuid) {
176
+ throw new Error(`Invalid purpose data: missing uuid`);
177
+ }
215
178
 
216
- // Only include enabled data elements (disabled elements are not selectable)
217
- const dataElements = (purpose.data_elements || [])
218
- .filter((element) => element.enabled)
219
- .map((element) => ({
220
- uuid: element.uuid,
221
- selected: element.required ? true : Boolean(element.selected),
222
- }));
223
-
224
- return {
225
- purpose_uuid: purpose.uuid,
226
- selected: Boolean(purpose.selected),
227
- data_elements: dataElements.length > 0 ? dataElements : undefined,
228
- };
229
- });
230
-
231
- payload = {
232
- notice_uuid: noticeUuid,
233
- purposes: validatedPurposes,
234
- select_all_mandatory: false,
235
- source: "WEB",
236
- declined: Boolean(declined),
237
- meta_data: meta_data ? { specific_uuid: meta_data.specific_uuid } : undefined,
179
+ // Only include enabled data elements (disabled elements are not selectable)
180
+ const dataElements = (purpose.data_elements || [])
181
+ .filter((element) => element.enabled)
182
+ .map((element) => ({
183
+ uuid: element.uuid,
184
+ selected: element.required ? true : Boolean(element.selected),
185
+ }));
186
+
187
+ return {
188
+ purpose_uuid: purpose.uuid,
189
+ selected: Boolean(purpose.selected),
190
+ data_elements: dataElements.length > 0 ? dataElements : undefined,
238
191
  };
239
- }
192
+ });
193
+
194
+ const payload: ConsentEventPayload = {
195
+ notice_uuid: noticeUuid,
196
+ purposes: validatedPurposes,
197
+ select_all_mandatory: false,
198
+ source: "WEB",
199
+ declined: Boolean(declined),
200
+ meta_data: meta_data ? { specific_uuid: meta_data.specific_uuid } : undefined,
201
+ };
240
202
 
241
203
  const response = await fetch(
242
204
  `${apiBaseUrl}/public/organisations/${ORGANISATION_UUID}/workspaces/${WORKSPACE_UUID}/submit-consent`,
@@ -175,31 +175,6 @@ export type ConsentEventPayload = {
175
175
  };
176
176
  };
177
177
 
178
- // @deprecated Remove when production backend supports the new payload format.
179
- export type LegacyConsentEventPayload = {
180
- primary_email?: string;
181
- notice_uuid: string;
182
- source: string;
183
- declined: boolean;
184
- consents: {
185
- purposes: Array<{
186
- uuid: string;
187
- name: string;
188
- description: string;
189
- industries?: string;
190
- selected: boolean;
191
- data_elements: Array<{
192
- uuid: string;
193
- name: string;
194
- enabled: boolean;
195
- required: boolean;
196
- selected: boolean;
197
- }>;
198
- }>;
199
- };
200
- meta_data?: { specific_uuid: string };
201
- };
202
-
203
178
  export type DataElement = {
204
179
  uuid: string;
205
180
  name: string;
@@ -1,11 +1,9 @@
1
1
  import type {
2
2
  ConsentContent,
3
3
  ConsentEventPayload,
4
- LegacyConsentEventPayload,
5
4
  FetchConsentContentParams,
6
5
  SubmitConsentEventParams,
7
6
  } from "./types";
8
- import { isLegacyApi } from "../../utils/isLegacyApi";
9
7
 
10
8
  const BASE_URL = "https://api.redacto.tech/consent";
11
9
 
@@ -77,68 +75,32 @@ export const submitConsentEvent = async ({
77
75
  try {
78
76
  const apiBaseUrl = baseUrl || BASE_URL;
79
77
 
80
- let payload: ConsentEventPayload | LegacyConsentEventPayload;
81
-
82
- if (isLegacyApi(apiBaseUrl)) {
83
- // @deprecated Legacy payload for production (.io) backend
84
- const primaryEmail = typeof window !== "undefined" ? localStorage.getItem("userEmail") : null;
85
- payload = {
86
- primary_email: primaryEmail || undefined,
87
- notice_uuid: noticeUuid,
88
- source: "WEB",
89
- declined: Boolean(declined),
90
- consents: {
91
- purposes: purposes.map((purpose) => {
92
- if (!purpose.uuid) {
93
- throw new Error(`Invalid purpose data: missing uuid`);
94
- }
95
- return {
96
- uuid: purpose.uuid,
97
- name: purpose.name,
98
- description: purpose.description || "",
99
- industries: purpose.industries || "",
100
- selected: Boolean(purpose.selected),
101
- data_elements: (purpose.data_elements || []).map((element) => ({
102
- uuid: element.uuid,
103
- name: element.name,
104
- enabled: Boolean(element.enabled),
105
- required: Boolean(element.required),
106
- selected: element.required ? true : Boolean(element.selected),
107
- })),
108
- };
109
- }),
110
- },
111
- meta_data: meta_data ? { specific_uuid: meta_data.specific_uuid } : undefined,
112
- };
113
- } else {
114
- // New payload for staging (.tech) / localhost
115
- payload = {
116
- notice_uuid: noticeUuid,
117
- purposes: purposes.map((purpose) => {
118
- if (!purpose.uuid) {
119
- throw new Error(`Invalid purpose data: missing uuid`);
120
- }
121
-
122
- // Only include enabled data elements (disabled elements are not selectable)
123
- const dataElements = purpose.data_elements
124
- .filter((element) => element.enabled)
125
- .map((element) => ({
126
- uuid: element.uuid,
127
- selected: element.required ? true : Boolean(element.selected),
128
- }));
129
-
130
- return {
131
- purpose_uuid: purpose.uuid,
132
- selected: Boolean(purpose.selected),
133
- data_elements: dataElements.length > 0 ? dataElements : undefined,
134
- };
135
- }),
136
- select_all_mandatory: false,
137
- source: "WEB",
138
- declined,
139
- meta_data,
140
- };
141
- }
78
+ const payload: ConsentEventPayload = {
79
+ notice_uuid: noticeUuid,
80
+ purposes: purposes.map((purpose) => {
81
+ if (!purpose.uuid) {
82
+ throw new Error(`Invalid purpose data: missing uuid`);
83
+ }
84
+
85
+ // Only include enabled data elements (disabled elements are not selectable)
86
+ const dataElements = purpose.data_elements
87
+ .filter((element) => element.enabled)
88
+ .map((element) => ({
89
+ uuid: element.uuid,
90
+ selected: element.required ? true : Boolean(element.selected),
91
+ }));
92
+
93
+ return {
94
+ purpose_uuid: purpose.uuid,
95
+ selected: Boolean(purpose.selected),
96
+ data_elements: dataElements.length > 0 ? dataElements : undefined,
97
+ };
98
+ }),
99
+ select_all_mandatory: false,
100
+ source: "WEB",
101
+ declined,
102
+ meta_data,
103
+ };
142
104
 
143
105
  const response = await fetch(
144
106
  `${apiBaseUrl}/public/organisations/${org_uuid}/workspaces/${workspace_uuid}/submit-consent`,
@@ -151,31 +151,6 @@ export type ConsentEventPayload = {
151
151
  };
152
152
  };
153
153
 
154
- // @deprecated Remove when production backend supports the new payload format.
155
- export type LegacyConsentEventPayload = {
156
- primary_email?: string;
157
- notice_uuid: string;
158
- source: string;
159
- declined: boolean;
160
- consents: {
161
- purposes: Array<{
162
- uuid: string;
163
- name: string;
164
- description: string;
165
- industries?: string;
166
- selected: boolean;
167
- data_elements: Array<{
168
- uuid: string;
169
- name: string;
170
- enabled: boolean;
171
- required: boolean;
172
- selected: boolean;
173
- }>;
174
- }>;
175
- };
176
- meta_data?: { specific_uuid: string };
177
- };
178
-
179
154
  export type DataElement = {
180
155
  uuid: string;
181
156
  name: string;
@@ -1,12 +0,0 @@
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
- }