@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.
- package/.turbo/turbo-build.log +21 -0
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +49 -2
- package/dist/index.d.ts +49 -2
- package/dist/index.js +1806 -345
- package/dist/index.mjs +1805 -345
- package/package.json +1 -1
- package/src/RedactoNoticeConsent/RedactoNoticeConsent.test.tsx +201 -118
- package/src/RedactoNoticeConsent/RedactoNoticeConsent.tsx +1192 -93
- package/src/RedactoNoticeConsent/api/index.ts +335 -246
- package/src/RedactoNoticeConsent/api/types.ts +138 -41
- package/src/RedactoNoticeConsent/components/DigiLockerCallback.tsx +536 -0
- package/src/RedactoNoticeConsent/components/index.ts +7 -0
- package/src/RedactoNoticeConsent/injectStyles.ts +11 -0
- package/src/RedactoNoticeConsent/services/storage.ts +122 -0
- package/src/RedactoNoticeConsent/types.ts +2 -0
- package/src/RedactoNoticeConsentInline/api/index.ts +26 -64
- package/src/RedactoNoticeConsentInline/api/types.ts +0 -25
- package/src/index.ts +10 -0
- package/src/utils/isLegacyApi.ts +0 -12
|
@@ -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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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";
|
package/src/utils/isLegacyApi.ts
DELETED
|
@@ -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
|
-
}
|