@redacto.io/consent-sdk-react 3.4.0 → 4.0.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.
@@ -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;
package/src/index.ts CHANGED
@@ -1,2 +1,12 @@
1
1
  export { default as RedactoNoticeConsent } from "./RedactoNoticeConsent";
2
2
  export { default as RedactoNoticeConsentInline } from "./RedactoNoticeConsentInline";
3
+
4
+ // Guardian Verification Components
5
+ export { DigiLockerCallback } from "./RedactoNoticeConsent/components/DigiLockerCallback";
6
+
7
+ // Types for Guardian Verification
8
+ export type {
9
+ DigiLockerCallbackProps,
10
+ ConsentFlowState,
11
+ GuardianVerificationErrorCode,
12
+ } from "./RedactoNoticeConsent/api/types";
@@ -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
- }