@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.
- package/.turbo/turbo-build.log +11 -11
- package/CHANGELOG.md +109 -0
- package/README.md +78 -0
- package/dist/{chunk-6A665OPR.mjs → chunk-OGL6OC3A.mjs} +4 -0
- package/dist/index.d.mts +32 -4
- package/dist/index.d.ts +32 -4
- package/dist/index.js +340 -230
- package/dist/index.mjs +339 -231
- package/dist/privacy-center.d.mts +55 -12
- package/dist/privacy-center.d.ts +55 -12
- package/dist/privacy-center.js +848 -950
- package/dist/privacy-center.mjs +698 -802
- package/package.json +1 -1
- package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.test.tsx +87 -0
- package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.tsx +27 -0
- package/src/RedactoNoticeAssisted/api/index.ts +7 -1
- package/src/RedactoNoticeAssisted/api/types.ts +2 -0
- package/src/RedactoNoticeAssisted/i18n.ts +0 -55
- package/src/RedactoNoticeAssisted/types.ts +2 -0
- package/src/RedactoNoticeConsent/RedactoNoticeConsent.test.tsx +42 -8
- package/src/RedactoNoticeConsent/RedactoNoticeConsent.tsx +74 -33
- package/src/RedactoNoticeConsent/api/index.ts +88 -175
- package/src/RedactoNoticeConsent/api/sandbox.ts +150 -0
- package/src/RedactoNoticeConsent/api/types.ts +58 -43
- package/src/RedactoNoticeConsent/language-codes.ts +0 -2
- package/src/RedactoNoticeConsent/types.ts +28 -2
- package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.tsx +85 -5
- package/src/RedactoNoticeConsentInline/api/index.ts +10 -1
- package/src/RedactoNoticeConsentInline/api/notice-read-routing.test.ts +72 -0
- package/src/RedactoNoticeConsentInline/api/types.ts +2 -0
- package/src/RedactoPrivacyCenter/RedactoPrivacyCenter.tsx +37 -2
- package/src/RedactoPrivacyCenter/api/actions.ts +3 -1
- package/src/RedactoPrivacyCenter/api/client.ts +122 -25
- package/src/RedactoPrivacyCenter/api/fetcher.ts +24 -9
- package/src/RedactoPrivacyCenter/components/AppShell/AppShell.tsx +28 -0
- package/src/RedactoPrivacyCenter/components/AppShell/UserMenu.tsx +47 -45
- package/src/RedactoPrivacyCenter/components/ConsentManager.tsx +2 -1
- package/src/RedactoPrivacyCenter/components/Form.tsx +55 -30
- package/src/RedactoPrivacyCenter/components/ModifyConsentModal.tsx +1 -1
- package/src/RedactoPrivacyCenter/components/SelectUser.tsx +25 -13
- package/src/RedactoPrivacyCenter/components/SelectUserGate.tsx +8 -6
- package/src/RedactoPrivacyCenter/components/constant.ts +3 -3
- package/src/RedactoPrivacyCenter/components/groupHelpers.ts +42 -6
- package/src/RedactoPrivacyCenter/context/AuthContext.tsx +131 -39
- package/src/RedactoPrivacyCenter/context/types.ts +38 -0
- package/src/RedactoPrivacyCenter/lib/api.ts +3 -0
- package/src/RedactoPrivacyCenter/lib/constants.ts +12 -6
- package/src/RedactoPrivacyCenter/lib/locales.ts +0 -3
- package/src/RedactoPrivacyCenter/lib/sandbox.ts +104 -0
- package/src/RedactoPrivacyCenter/lib/types.ts +25 -1
- package/src/RedactoPrivacyCenter/lib/utils.ts +15 -0
- package/src/RedactoPrivacyCenter/locales/as/translation.json +3 -3
- package/src/RedactoPrivacyCenter/locales/bn/translation.json +3 -3
- package/src/RedactoPrivacyCenter/locales/brx/translation.json +3 -3
- package/src/RedactoPrivacyCenter/locales/doi/translation.json +3 -3
- package/src/RedactoPrivacyCenter/locales/en/translation.json +4 -3
- package/src/RedactoPrivacyCenter/locales/gom/translation.json +3 -3
- package/src/RedactoPrivacyCenter/locales/gu/translation.json +3 -3
- package/src/RedactoPrivacyCenter/locales/hi/translation.json +3 -3
- package/src/RedactoPrivacyCenter/locales/kn/translation.json +3 -3
- package/src/RedactoPrivacyCenter/locales/ks/translation.json +3 -3
- package/src/RedactoPrivacyCenter/locales/mai/translation.json +3 -3
- package/src/RedactoPrivacyCenter/locales/ml/translation.json +3 -3
- package/src/RedactoPrivacyCenter/locales/mni-Mtei/translation.json +3 -3
- package/src/RedactoPrivacyCenter/locales/mr/translation.json +3 -3
- package/src/RedactoPrivacyCenter/locales/ne/translation.json +3 -3
- package/src/RedactoPrivacyCenter/locales/or/translation.json +3 -3
- package/src/RedactoPrivacyCenter/locales/pa/translation.json +3 -3
- package/src/RedactoPrivacyCenter/locales/sa/translation.json +3 -3
- package/src/RedactoPrivacyCenter/locales/sat/translation.json +3 -3
- package/src/RedactoPrivacyCenter/locales/sd/translation.json +3 -3
- package/src/RedactoPrivacyCenter/locales/ta/translation.json +3 -3
- package/src/RedactoPrivacyCenter/locales/te/translation.json +3 -3
- package/src/RedactoPrivacyCenter/locales/ur/translation.json +3 -3
- package/src/RedactoPrivacyCenter/styles/injectStyles.ts +7 -2
- package/src/RedactoPrivacyCenter/styles/pcStyles.ts +17 -0
- package/src/RedactoPrivacyCenter/ui/PCAvatar.test.tsx +83 -0
- package/src/RedactoPrivacyCenter/ui/PCAvatar.tsx +33 -9
- package/src/shared/notice-consent-status.ts +190 -0
- package/src/shared/sandbox.ts +6 -0
- package/tests/Form.test.tsx +142 -5
- package/tests/RevokeWarningMessage.test.tsx +151 -0
- package/tests/consentClient.test.ts +46 -0
- package/src/RedactoPrivacyCenter/locales/bho/translation.json +0 -340
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
32
32
|
var import_react2 = require("react");
|
|
33
33
|
|
|
34
34
|
// src/RedactoNoticeConsent/api/index.ts
|
|
35
|
-
var
|
|
35
|
+
var import_jwt_decode2 = require("jwt-decode");
|
|
36
36
|
|
|
37
37
|
// src/shared/api-errors.ts
|
|
38
38
|
var ApiError = class extends Error {
|
|
@@ -92,6 +92,144 @@ async function parseApiError(response, fallbackMessage) {
|
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
// src/shared/sandbox.ts
|
|
96
|
+
var SANDBOX_TOKEN_HEADER = "X-Consent-Token";
|
|
97
|
+
|
|
98
|
+
// src/RedactoNoticeConsent/api/sandbox.ts
|
|
99
|
+
var resolveSandboxAuth = (params) => {
|
|
100
|
+
var _a, _b, _c, _d, _e;
|
|
101
|
+
const token = (_a = params.token) == null ? void 0 : _a.trim();
|
|
102
|
+
if (!token) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
const organisationUuid = (_b = params.organisationUuid) == null ? void 0 : _b.trim();
|
|
106
|
+
const workspaceUuid = (_c = params.workspaceUuid) == null ? void 0 : _c.trim();
|
|
107
|
+
const ucic = (_d = params.sandboxUcic) == null ? void 0 : _d.trim();
|
|
108
|
+
const subject = (_e = params.sandboxSubject) == null ? void 0 : _e.trim();
|
|
109
|
+
if (!organisationUuid || !workspaceUuid) {
|
|
110
|
+
throw new Error(
|
|
111
|
+
"Sandbox mode requires organisationUuid and workspaceUuid props"
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
if (!ucic && !subject) {
|
|
115
|
+
throw new Error("Sandbox mode requires a UCIC, email, or mobile");
|
|
116
|
+
}
|
|
117
|
+
return { token, ucic, subject: subject != null ? subject : "", organisationUuid, workspaceUuid };
|
|
118
|
+
};
|
|
119
|
+
var resolveRequestAuth = (accessToken, sandboxParams, decodeTokenSafely2) => {
|
|
120
|
+
const sandbox = resolveSandboxAuth(sandboxParams);
|
|
121
|
+
if (sandbox) {
|
|
122
|
+
return {
|
|
123
|
+
organisationUuid: sandbox.organisationUuid,
|
|
124
|
+
workspaceUuid: sandbox.workspaceUuid,
|
|
125
|
+
sandbox
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
const decodedToken = accessToken ? decodeTokenSafely2(accessToken) : null;
|
|
129
|
+
if (!decodedToken) {
|
|
130
|
+
throw new Error("Invalid access token");
|
|
131
|
+
}
|
|
132
|
+
const { organisation_uuid, workspace_uuid } = decodedToken;
|
|
133
|
+
if (!organisation_uuid || !workspace_uuid) {
|
|
134
|
+
throw new Error("Invalid token: missing organization or workspace UUID");
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
organisationUuid: organisation_uuid,
|
|
138
|
+
workspaceUuid: workspace_uuid,
|
|
139
|
+
sandbox: null
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
var buildAuthHeaders = (accessToken, sandbox) => {
|
|
143
|
+
if (sandbox) {
|
|
144
|
+
return { [SANDBOX_TOKEN_HEADER]: sandbox.token };
|
|
145
|
+
}
|
|
146
|
+
return { Authorization: `Bearer ${accessToken}` };
|
|
147
|
+
};
|
|
148
|
+
var sandboxBodyIdentity = (sandbox) => {
|
|
149
|
+
if (sandbox.ucic) {
|
|
150
|
+
return { org_user_id: sandbox.ucic };
|
|
151
|
+
}
|
|
152
|
+
return sandbox.subject.includes("@") ? { primary_email: sandbox.subject } : { primary_mobile: sandbox.subject };
|
|
153
|
+
};
|
|
154
|
+
var sandboxQueryIdentity = (sandbox) => sandboxBodyIdentity(sandbox);
|
|
155
|
+
|
|
156
|
+
// src/shared/notice-consent-status.ts
|
|
157
|
+
var import_jwt_decode = require("jwt-decode");
|
|
158
|
+
var decodeNoticeConsentToken = (token) => {
|
|
159
|
+
try {
|
|
160
|
+
return (0, import_jwt_decode.jwtDecode)(token);
|
|
161
|
+
} catch {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
var fetchNoticeConsentStatusForScope = async ({
|
|
166
|
+
accessToken,
|
|
167
|
+
ledgerBaseUrl,
|
|
168
|
+
organisationUuid,
|
|
169
|
+
workspaceUuid,
|
|
170
|
+
noticeUuid,
|
|
171
|
+
signal
|
|
172
|
+
}) => {
|
|
173
|
+
if (!accessToken || !ledgerBaseUrl || !organisationUuid || !workspaceUuid || !noticeUuid) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
try {
|
|
177
|
+
const response = await fetch(
|
|
178
|
+
`${ledgerBaseUrl}/public/organisations/${organisationUuid}/workspaces/${workspaceUuid}/notices/${noticeUuid}/check-consent`,
|
|
179
|
+
{
|
|
180
|
+
method: "POST",
|
|
181
|
+
headers: {
|
|
182
|
+
Authorization: `Bearer ${accessToken}`,
|
|
183
|
+
"Content-Type": "application/json"
|
|
184
|
+
},
|
|
185
|
+
body: "{}",
|
|
186
|
+
signal
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
if (!response.ok) {
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
const data = await response.json();
|
|
193
|
+
const body = data && typeof data === "object" && "detail" in data && data.detail ? data.detail : data;
|
|
194
|
+
if (!body || !Array.isArray(body.purposes)) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
return body;
|
|
198
|
+
} catch {
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
var fetchNoticeConsentStatus = async ({
|
|
203
|
+
accessToken,
|
|
204
|
+
ledgerBaseUrl,
|
|
205
|
+
noticeUuid,
|
|
206
|
+
signal
|
|
207
|
+
}) => {
|
|
208
|
+
if (!accessToken || !ledgerBaseUrl || !noticeUuid) {
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
const decodedToken = decodeNoticeConsentToken(accessToken);
|
|
212
|
+
if (!decodedToken) {
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
const {
|
|
216
|
+
organisation_uuid: ORGANISATION_UUID,
|
|
217
|
+
workspace_uuid: WORKSPACE_UUID
|
|
218
|
+
} = decodedToken;
|
|
219
|
+
if (!ORGANISATION_UUID || !WORKSPACE_UUID) {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
return fetchNoticeConsentStatusForScope({
|
|
223
|
+
accessToken,
|
|
224
|
+
ledgerBaseUrl,
|
|
225
|
+
organisationUuid: ORGANISATION_UUID,
|
|
226
|
+
workspaceUuid: WORKSPACE_UUID,
|
|
227
|
+
noticeUuid,
|
|
228
|
+
signal
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
var isNoticeFullyConsented = (status) => status.consented && status.all_mandatory_active;
|
|
232
|
+
|
|
95
233
|
// src/RedactoNoticeConsent/api/index.ts
|
|
96
234
|
var BASE_URL = "https://api.redacto.io/consent";
|
|
97
235
|
var apiCache = /* @__PURE__ */ new Map();
|
|
@@ -111,7 +249,7 @@ function setCachedData(key, data, ttl = CACHE_TTL) {
|
|
|
111
249
|
}
|
|
112
250
|
function decodeTokenSafely(token) {
|
|
113
251
|
try {
|
|
114
|
-
return (0,
|
|
252
|
+
return (0, import_jwt_decode2.jwtDecode)(token);
|
|
115
253
|
} catch (error) {
|
|
116
254
|
console.warn("Failed to decode JWT token:", error);
|
|
117
255
|
return null;
|
|
@@ -128,21 +266,19 @@ var fetchConsentContent = async ({
|
|
|
128
266
|
specific_uuid,
|
|
129
267
|
validate_against = "all",
|
|
130
268
|
include_fully_consented_data = false,
|
|
131
|
-
signal
|
|
269
|
+
signal,
|
|
270
|
+
...sandboxParams
|
|
132
271
|
}) => {
|
|
133
|
-
if (!noticeId || !
|
|
134
|
-
throw new Error("noticeId
|
|
272
|
+
if (!noticeId || !validate_against) {
|
|
273
|
+
throw new Error("noticeId is required");
|
|
135
274
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
throw new Error("Invalid access token");
|
|
139
|
-
}
|
|
140
|
-
const { organisation_uuid: ORGANISATION_UUID, workspace_uuid: WORKSPACE_UUID } = decodedToken;
|
|
141
|
-
if (!ORGANISATION_UUID || !WORKSPACE_UUID) {
|
|
142
|
-
throw new Error("Invalid token: missing organization or workspace UUID");
|
|
275
|
+
if (!accessToken && !sandboxParams.token) {
|
|
276
|
+
throw new Error("accessToken or token is required");
|
|
143
277
|
}
|
|
278
|
+
const { organisationUuid: ORGANISATION_UUID, workspaceUuid: WORKSPACE_UUID, sandbox } = resolveRequestAuth(accessToken, sandboxParams, decodeTokenSafely);
|
|
144
279
|
const apiBaseUrl = baseUrl || BASE_URL;
|
|
145
|
-
const
|
|
280
|
+
const cacheIdentity = sandbox ? `sandbox:${sandbox.organisationUuid}:${sandbox.workspaceUuid}:${sandbox.ucic || sandbox.subject}` : accessToken;
|
|
281
|
+
const cacheKey = `${cacheIdentity}-${noticeId}-${validate_against}-${language}-${specific_uuid || ""}-${include_fully_consented_data}`;
|
|
146
282
|
if (validate_against === "all" && !specific_uuid) {
|
|
147
283
|
const cachedData = getCachedData(cacheKey);
|
|
148
284
|
if (cachedData) {
|
|
@@ -159,10 +295,15 @@ var fetchConsentContent = async ({
|
|
|
159
295
|
if (include_fully_consented_data) {
|
|
160
296
|
url.searchParams.append("include_fully_consented_data", "true");
|
|
161
297
|
}
|
|
298
|
+
if (sandbox) {
|
|
299
|
+
for (const [key, value] of Object.entries(sandboxQueryIdentity(sandbox))) {
|
|
300
|
+
url.searchParams.append(key, value);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
162
303
|
const response = await fetch(url.toString(), {
|
|
163
304
|
method: "GET",
|
|
164
305
|
headers: {
|
|
165
|
-
|
|
306
|
+
...buildAuthHeaders(accessToken, sandbox),
|
|
166
307
|
"Accept-Language": language
|
|
167
308
|
},
|
|
168
309
|
signal
|
|
@@ -190,20 +331,17 @@ var submitConsentEvent = async ({
|
|
|
190
331
|
meta_data,
|
|
191
332
|
guardianVerificationReference,
|
|
192
333
|
selfDeclaredAdult,
|
|
193
|
-
signal
|
|
334
|
+
signal,
|
|
335
|
+
...sandboxParams
|
|
194
336
|
}) => {
|
|
195
|
-
if (!noticeUuid || !
|
|
196
|
-
throw new Error("noticeUuid
|
|
197
|
-
}
|
|
198
|
-
const decodedToken = decodeTokenSafely(accessToken);
|
|
199
|
-
if (!decodedToken) {
|
|
200
|
-
throw new Error("Invalid access token");
|
|
337
|
+
if (!noticeUuid || !Array.isArray(purposes)) {
|
|
338
|
+
throw new Error("noticeUuid and purposes array are required");
|
|
201
339
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
throw new Error("Invalid token: missing organization or workspace UUID");
|
|
340
|
+
if (!accessToken && !sandboxParams.token) {
|
|
341
|
+
throw new Error("accessToken or token is required");
|
|
205
342
|
}
|
|
206
|
-
const
|
|
343
|
+
const { organisationUuid: ORGANISATION_UUID, workspaceUuid: WORKSPACE_UUID, sandbox } = resolveRequestAuth(accessToken, sandboxParams, decodeTokenSafely);
|
|
344
|
+
const apiBaseUrl = (sandbox ? null : ledgerBaseUrl) || baseUrl || BASE_URL;
|
|
207
345
|
const validatedPurposes = purposes.map((purpose) => {
|
|
208
346
|
if (!purpose.uuid) {
|
|
209
347
|
throw new Error(`Invalid purpose data: missing uuid`);
|
|
@@ -229,15 +367,16 @@ var submitConsentEvent = async ({
|
|
|
229
367
|
guardian_verification_reference: guardianVerificationReference,
|
|
230
368
|
self_declared_adult: selfDeclaredAdult
|
|
231
369
|
};
|
|
370
|
+
const requestBody = sandbox ? { ...payload, ...sandboxBodyIdentity(sandbox) } : payload;
|
|
232
371
|
const response = await fetch(
|
|
233
372
|
`${apiBaseUrl}/public/organisations/${ORGANISATION_UUID}/workspaces/${WORKSPACE_UUID}/submit-consent`,
|
|
234
373
|
{
|
|
235
374
|
method: "POST",
|
|
236
375
|
headers: {
|
|
237
|
-
|
|
376
|
+
...buildAuthHeaders(accessToken, sandbox),
|
|
238
377
|
"Content-Type": "application/json"
|
|
239
378
|
},
|
|
240
|
-
body: JSON.stringify(
|
|
379
|
+
body: JSON.stringify(requestBody),
|
|
241
380
|
signal
|
|
242
381
|
}
|
|
243
382
|
);
|
|
@@ -249,112 +388,32 @@ var submitConsentEvent = async ({
|
|
|
249
388
|
}
|
|
250
389
|
apiCache.clear();
|
|
251
390
|
};
|
|
252
|
-
var fetchNoticeConsentStatus = async ({
|
|
253
|
-
accessToken,
|
|
254
|
-
ledgerBaseUrl,
|
|
255
|
-
noticeUuid,
|
|
256
|
-
signal
|
|
257
|
-
}) => {
|
|
258
|
-
if (!accessToken || !ledgerBaseUrl || !noticeUuid) {
|
|
259
|
-
return null;
|
|
260
|
-
}
|
|
261
|
-
const decodedToken = decodeTokenSafely(accessToken);
|
|
262
|
-
if (!decodedToken) {
|
|
263
|
-
return null;
|
|
264
|
-
}
|
|
265
|
-
const { organisation_uuid: ORGANISATION_UUID, workspace_uuid: WORKSPACE_UUID } = decodedToken;
|
|
266
|
-
if (!ORGANISATION_UUID || !WORKSPACE_UUID) {
|
|
267
|
-
return null;
|
|
268
|
-
}
|
|
269
|
-
try {
|
|
270
|
-
const response = await fetch(
|
|
271
|
-
`${ledgerBaseUrl}/public/organisations/${ORGANISATION_UUID}/workspaces/${WORKSPACE_UUID}/notices/${noticeUuid}/check-consent`,
|
|
272
|
-
{
|
|
273
|
-
method: "POST",
|
|
274
|
-
headers: {
|
|
275
|
-
Authorization: `Bearer ${accessToken}`,
|
|
276
|
-
"Content-Type": "application/json"
|
|
277
|
-
},
|
|
278
|
-
body: "{}",
|
|
279
|
-
signal
|
|
280
|
-
}
|
|
281
|
-
);
|
|
282
|
-
if (!response.ok) {
|
|
283
|
-
return null;
|
|
284
|
-
}
|
|
285
|
-
const data = await response.json();
|
|
286
|
-
const body = data && typeof data === "object" && "detail" in data && data.detail ? data.detail : data;
|
|
287
|
-
if (!body || !Array.isArray(body.purposes)) {
|
|
288
|
-
return null;
|
|
289
|
-
}
|
|
290
|
-
return body;
|
|
291
|
-
} catch {
|
|
292
|
-
return null;
|
|
293
|
-
}
|
|
294
|
-
};
|
|
295
|
-
var buildLedgerConsentOverlay = (status, configPurposes) => {
|
|
296
|
-
var _a, _b;
|
|
297
|
-
const byUuid = new Map(status.purposes.map((p) => [p.uuid, p]));
|
|
298
|
-
const hasHistory = status.purposes.some(
|
|
299
|
-
(p) => (p.status || "INACTIVE") !== "INACTIVE"
|
|
300
|
-
);
|
|
301
|
-
if (!hasHistory) {
|
|
302
|
-
return null;
|
|
303
|
-
}
|
|
304
|
-
const purpose_selections = {};
|
|
305
|
-
for (const cp of configPurposes) {
|
|
306
|
-
const lp = byUuid.get(cp.uuid);
|
|
307
|
-
const purposeStatus = (lp == null ? void 0 : lp.status) || "INACTIVE";
|
|
308
|
-
const selectedByUuid = new Map(
|
|
309
|
-
((lp == null ? void 0 : lp.data_elements) || []).map((de) => [de.uuid, de.selected])
|
|
310
|
-
);
|
|
311
|
-
const data_elements = {};
|
|
312
|
-
for (const de of cp.data_elements) {
|
|
313
|
-
data_elements[de.uuid] = {
|
|
314
|
-
selected: (_a = selectedByUuid.get(de.uuid)) != null ? _a : false,
|
|
315
|
-
enabled: de.enabled,
|
|
316
|
-
required: de.required
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
purpose_selections[cp.uuid] = {
|
|
320
|
-
selected: (_b = lp == null ? void 0 : lp.selected) != null ? _b : false,
|
|
321
|
-
status: purposeStatus,
|
|
322
|
-
needs_reconsent: purposeStatus !== "ACTIVE",
|
|
323
|
-
data_elements
|
|
324
|
-
};
|
|
325
|
-
}
|
|
326
|
-
const reconsent_required = configPurposes.some(
|
|
327
|
-
(cp) => {
|
|
328
|
-
var _a2;
|
|
329
|
-
return (((_a2 = purpose_selections[cp.uuid]) == null ? void 0 : _a2.status) || "INACTIVE") !== "ACTIVE";
|
|
330
|
-
}
|
|
331
|
-
);
|
|
332
|
-
return { reconsent_required, purpose_selections };
|
|
333
|
-
};
|
|
334
391
|
var fetchTTSAudioUrls = async ({
|
|
335
392
|
accessToken,
|
|
336
393
|
baseUrl,
|
|
394
|
+
ledgerBaseUrl,
|
|
337
395
|
noticeUuid,
|
|
338
396
|
language,
|
|
339
|
-
signal
|
|
397
|
+
signal,
|
|
398
|
+
...sandboxParams
|
|
340
399
|
}) => {
|
|
341
|
-
if (!accessToken || !noticeUuid || !language) {
|
|
342
|
-
throw new Error("accessToken, noticeUuid, and language are required");
|
|
400
|
+
if (!accessToken && !sandboxParams.token || !noticeUuid || !language) {
|
|
401
|
+
throw new Error("accessToken (or token), noticeUuid, and language are required");
|
|
343
402
|
}
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
if (
|
|
350
|
-
|
|
403
|
+
const { organisationUuid: ORGANISATION_UUID, workspaceUuid: WORKSPACE_UUID, sandbox } = resolveRequestAuth(accessToken, sandboxParams, decodeTokenSafely);
|
|
404
|
+
const apiBaseUrl = (sandbox ? null : ledgerBaseUrl) || baseUrl || BASE_URL;
|
|
405
|
+
const url = new URL(
|
|
406
|
+
`${apiBaseUrl}/public/organisations/${ORGANISATION_UUID}/workspaces/${WORKSPACE_UUID}/notices/${noticeUuid}/audio/${language}`
|
|
407
|
+
);
|
|
408
|
+
if (sandbox) {
|
|
409
|
+
for (const [key, value] of Object.entries(sandboxQueryIdentity(sandbox))) {
|
|
410
|
+
url.searchParams.append(key, value);
|
|
411
|
+
}
|
|
351
412
|
}
|
|
352
|
-
const
|
|
353
|
-
const url = `${apiBaseUrl}/public/organisations/${ORGANISATION_UUID}/workspaces/${WORKSPACE_UUID}/notices/${noticeUuid}/audio/${language}`;
|
|
354
|
-
const response = await fetch(url, {
|
|
413
|
+
const response = await fetch(url.toString(), {
|
|
355
414
|
method: "GET",
|
|
356
415
|
headers: {
|
|
357
|
-
|
|
416
|
+
...buildAuthHeaders(accessToken, sandbox),
|
|
358
417
|
Accept: "application/json"
|
|
359
418
|
},
|
|
360
419
|
signal
|
|
@@ -396,7 +455,10 @@ var initiateGuardianVerification = async ({
|
|
|
396
455
|
if (!decodedToken) {
|
|
397
456
|
throw new Error("Invalid access token");
|
|
398
457
|
}
|
|
399
|
-
const {
|
|
458
|
+
const {
|
|
459
|
+
organisation_uuid: ORGANISATION_UUID,
|
|
460
|
+
workspace_uuid: WORKSPACE_UUID
|
|
461
|
+
} = decodedToken;
|
|
400
462
|
if (!ORGANISATION_UUID || !WORKSPACE_UUID) {
|
|
401
463
|
throw new Error("Invalid token: missing organization or workspace UUID");
|
|
402
464
|
}
|
|
@@ -470,7 +532,10 @@ var verifyGuardianStatus = async ({
|
|
|
470
532
|
if (!decodedToken) {
|
|
471
533
|
throw new Error("Invalid access token");
|
|
472
534
|
}
|
|
473
|
-
const {
|
|
535
|
+
const {
|
|
536
|
+
organisation_uuid: ORGANISATION_UUID,
|
|
537
|
+
workspace_uuid: WORKSPACE_UUID
|
|
538
|
+
} = decodedToken;
|
|
474
539
|
if (!ORGANISATION_UUID || !WORKSPACE_UUID) {
|
|
475
540
|
throw new Error("Invalid token: missing organization or workspace UUID");
|
|
476
541
|
}
|
|
@@ -483,9 +548,7 @@ var verifyGuardianStatus = async ({
|
|
|
483
548
|
Authorization: `Bearer ${accessToken}`,
|
|
484
549
|
"Content-Type": "application/json"
|
|
485
550
|
},
|
|
486
|
-
body: JSON.stringify({
|
|
487
|
-
session_token: sessionToken
|
|
488
|
-
}),
|
|
551
|
+
body: JSON.stringify({ session_token: sessionToken }),
|
|
489
552
|
signal
|
|
490
553
|
}
|
|
491
554
|
);
|
|
@@ -528,7 +591,6 @@ var LANGUAGE_NATIVE_LABELS = {
|
|
|
528
591
|
English: "English",
|
|
529
592
|
Assamese: "\u0985\u09B8\u09AE\u09C0\u09AF\u09BC\u09BE (Assamese)",
|
|
530
593
|
Bengali: "\u09AC\u09BE\u0982\u09B2\u09BE (Bengali)",
|
|
531
|
-
Bhojpuri: "\u092D\u094B\u091C\u092A\u0941\u0930\u0940 (Bhojpuri)",
|
|
532
594
|
Bodo: "\u092C\u0921\u093C\u094B (Bodo)",
|
|
533
595
|
Dogri: "\u0921\u094B\u0917\u0930\u0940 (Dogri)",
|
|
534
596
|
Gujarati: "\u0A97\u0AC1\u0A9C\u0AB0\u0ABE\u0AA4\u0AC0 (Gujarati)",
|
|
@@ -558,7 +620,6 @@ var LANGUAGE_NAME_TO_BCP47 = {
|
|
|
558
620
|
English: "en",
|
|
559
621
|
Assamese: "as",
|
|
560
622
|
Bengali: "bn",
|
|
561
|
-
Bhojpuri: "bho",
|
|
562
623
|
Bodo: "brx",
|
|
563
624
|
Dogri: "doi",
|
|
564
625
|
Gujarati: "gu",
|
|
@@ -2376,6 +2437,12 @@ var RedactoNoticeConsent = ({
|
|
|
2376
2437
|
noticeId,
|
|
2377
2438
|
accessToken,
|
|
2378
2439
|
refreshToken,
|
|
2440
|
+
token,
|
|
2441
|
+
email,
|
|
2442
|
+
mobile,
|
|
2443
|
+
ucic,
|
|
2444
|
+
organisationUuid,
|
|
2445
|
+
workspaceUuid,
|
|
2379
2446
|
baseUrl,
|
|
2380
2447
|
ledgerBaseUrl,
|
|
2381
2448
|
language = "en",
|
|
@@ -2394,15 +2461,43 @@ var RedactoNoticeConsent = ({
|
|
|
2394
2461
|
reviewModeButtonText = "Continue"
|
|
2395
2462
|
}) => {
|
|
2396
2463
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
2464
|
+
const sandboxParams = (0, import_react2.useMemo)(
|
|
2465
|
+
() => ({
|
|
2466
|
+
token,
|
|
2467
|
+
sandboxUcic: ucic,
|
|
2468
|
+
sandboxSubject: email || mobile,
|
|
2469
|
+
organisationUuid,
|
|
2470
|
+
workspaceUuid
|
|
2471
|
+
}),
|
|
2472
|
+
[token, ucic, email, mobile, organisationUuid, workspaceUuid]
|
|
2473
|
+
);
|
|
2397
2474
|
const propValidationError = (0, import_react2.useMemo)(() => {
|
|
2398
2475
|
if (!(noticeId == null ? void 0 : noticeId.trim())) {
|
|
2399
2476
|
return "RedactoNoticeConsent: 'noticeId' prop is required and cannot be empty";
|
|
2400
2477
|
}
|
|
2478
|
+
if (token == null ? void 0 : token.trim()) {
|
|
2479
|
+
if (!(organisationUuid == null ? void 0 : organisationUuid.trim()) || !(workspaceUuid == null ? void 0 : workspaceUuid.trim())) {
|
|
2480
|
+
return "RedactoNoticeConsent: sandbox mode requires 'organisationUuid' and 'workspaceUuid'";
|
|
2481
|
+
}
|
|
2482
|
+
if (!(email == null ? void 0 : email.trim()) && !(mobile == null ? void 0 : mobile.trim()) && !(ucic == null ? void 0 : ucic.trim())) {
|
|
2483
|
+
return "RedactoNoticeConsent: sandbox mode requires 'email', 'mobile', or 'ucic'";
|
|
2484
|
+
}
|
|
2485
|
+
return null;
|
|
2486
|
+
}
|
|
2401
2487
|
if (!(accessToken == null ? void 0 : accessToken.trim())) {
|
|
2402
2488
|
return "RedactoNoticeConsent: 'accessToken' prop is required and cannot be empty";
|
|
2403
2489
|
}
|
|
2404
2490
|
return null;
|
|
2405
|
-
}, [
|
|
2491
|
+
}, [
|
|
2492
|
+
noticeId,
|
|
2493
|
+
accessToken,
|
|
2494
|
+
token,
|
|
2495
|
+
organisationUuid,
|
|
2496
|
+
workspaceUuid,
|
|
2497
|
+
email,
|
|
2498
|
+
mobile,
|
|
2499
|
+
ucic
|
|
2500
|
+
]);
|
|
2406
2501
|
if (propValidationError) {
|
|
2407
2502
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
2408
2503
|
"div",
|
|
@@ -2732,7 +2827,7 @@ var RedactoNoticeConsent = ({
|
|
|
2732
2827
|
return content.dpo_info[key] || defaultText;
|
|
2733
2828
|
};
|
|
2734
2829
|
const fetchNotice = async () => {
|
|
2735
|
-
var _a2
|
|
2830
|
+
var _a2;
|
|
2736
2831
|
if (isRequestInProgressRef.current) {
|
|
2737
2832
|
return;
|
|
2738
2833
|
}
|
|
@@ -2746,16 +2841,18 @@ var RedactoNoticeConsent = ({
|
|
|
2746
2841
|
setShowAgeVerification(false);
|
|
2747
2842
|
setShowGuardianForm(false);
|
|
2748
2843
|
try {
|
|
2844
|
+
const noticeBaseUrl = ledgerBaseUrl && !applicationId && !token ? ledgerBaseUrl : baseUrl;
|
|
2749
2845
|
const consentContentData = await fetchConsentContent({
|
|
2750
2846
|
noticeId,
|
|
2751
2847
|
accessToken,
|
|
2752
2848
|
refreshToken,
|
|
2753
|
-
baseUrl,
|
|
2849
|
+
baseUrl: noticeBaseUrl,
|
|
2754
2850
|
language,
|
|
2755
2851
|
specific_uuid: applicationId,
|
|
2756
2852
|
validate_against: validateAgainst,
|
|
2757
2853
|
include_fully_consented_data: includeFullyConsentedData,
|
|
2758
|
-
signal: (_a2 = abortControllerRef.current) == null ? void 0 : _a2.signal
|
|
2854
|
+
signal: (_a2 = abortControllerRef.current) == null ? void 0 : _a2.signal,
|
|
2855
|
+
...sandboxParams
|
|
2759
2856
|
});
|
|
2760
2857
|
const activeConfig = consentContentData.detail.active_config;
|
|
2761
2858
|
setContent(activeConfig);
|
|
@@ -2773,24 +2870,8 @@ var RedactoNoticeConsent = ({
|
|
|
2773
2870
|
{}
|
|
2774
2871
|
);
|
|
2775
2872
|
setCollapsedPurposes(initialCollapsedState);
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
if (ledgerBaseUrl && !applicationId) {
|
|
2779
|
-
const ledgerStatus = await fetchNoticeConsentStatus({
|
|
2780
|
-
accessToken,
|
|
2781
|
-
ledgerBaseUrl,
|
|
2782
|
-
noticeUuid: noticeId,
|
|
2783
|
-
signal: (_b2 = abortControllerRef.current) == null ? void 0 : _b2.signal
|
|
2784
|
-
});
|
|
2785
|
-
if (ledgerStatus) {
|
|
2786
|
-
const overlay = buildLedgerConsentOverlay(
|
|
2787
|
-
ledgerStatus,
|
|
2788
|
-
activeConfig.purposes
|
|
2789
|
-
);
|
|
2790
|
-
isReconsentRequired = (_c2 = overlay == null ? void 0 : overlay.reconsent_required) != null ? _c2 : false;
|
|
2791
|
-
purposeSelections = overlay == null ? void 0 : overlay.purpose_selections;
|
|
2792
|
-
}
|
|
2793
|
-
}
|
|
2873
|
+
const isReconsentRequired = consentContentData.detail.reconsent_required;
|
|
2874
|
+
const purposeSelections = consentContentData.detail.purpose_selections;
|
|
2794
2875
|
const newCategorizedPurposes = isReconsentRequired ? {
|
|
2795
2876
|
alreadyConsented: activeConfig.purposes.filter(
|
|
2796
2877
|
(purpose) => {
|
|
@@ -2821,9 +2902,9 @@ var RedactoNoticeConsent = ({
|
|
|
2821
2902
|
const initialDataElementState = activeConfig.purposes.reduce(
|
|
2822
2903
|
(acc, purpose) => {
|
|
2823
2904
|
purpose.data_elements.forEach((element) => {
|
|
2824
|
-
var _a3,
|
|
2905
|
+
var _a3, _b2;
|
|
2825
2906
|
const combinedId = `${purpose.uuid}-${element.uuid}`;
|
|
2826
|
-
if ((
|
|
2907
|
+
if ((_b2 = (_a3 = purposeSelections == null ? void 0 : purposeSelections[purpose.uuid]) == null ? void 0 : _a3.data_elements) == null ? void 0 : _b2[element.uuid]) {
|
|
2827
2908
|
acc[combinedId] = purposeSelections[purpose.uuid].data_elements[element.uuid].selected;
|
|
2828
2909
|
} else {
|
|
2829
2910
|
acc[combinedId] = false;
|
|
@@ -2839,9 +2920,9 @@ var RedactoNoticeConsent = ({
|
|
|
2839
2920
|
const initialSelections = {};
|
|
2840
2921
|
newCategorizedPurposes.alreadyConsented.forEach((purpose) => {
|
|
2841
2922
|
purpose.data_elements.forEach((element) => {
|
|
2842
|
-
var _a3,
|
|
2923
|
+
var _a3, _b2;
|
|
2843
2924
|
const combinedId = `${purpose.uuid}-${element.uuid}`;
|
|
2844
|
-
if ((
|
|
2925
|
+
if ((_b2 = (_a3 = purposeSelections == null ? void 0 : purposeSelections[purpose.uuid]) == null ? void 0 : _a3.data_elements) == null ? void 0 : _b2[element.uuid]) {
|
|
2845
2926
|
initialSelections[combinedId] = purposeSelections[purpose.uuid].data_elements[element.uuid].selected;
|
|
2846
2927
|
} else {
|
|
2847
2928
|
initialSelections[combinedId] = false;
|
|
@@ -2862,9 +2943,9 @@ var RedactoNoticeConsent = ({
|
|
|
2862
2943
|
activeConfig.purposes.forEach(
|
|
2863
2944
|
(purpose) => {
|
|
2864
2945
|
purpose.data_elements.forEach((element) => {
|
|
2865
|
-
var _a3,
|
|
2946
|
+
var _a3, _b2;
|
|
2866
2947
|
const combinedId = `${purpose.uuid}-${element.uuid}`;
|
|
2867
|
-
if ((
|
|
2948
|
+
if ((_b2 = (_a3 = purposeSelections[purpose.uuid]) == null ? void 0 : _a3.data_elements) == null ? void 0 : _b2[element.uuid]) {
|
|
2868
2949
|
initialSelections[combinedId] = purposeSelections[purpose.uuid].data_elements[element.uuid].selected;
|
|
2869
2950
|
} else {
|
|
2870
2951
|
initialSelections[combinedId] = false;
|
|
@@ -2912,8 +2993,10 @@ var RedactoNoticeConsent = ({
|
|
|
2912
2993
|
noticeId,
|
|
2913
2994
|
accessToken,
|
|
2914
2995
|
refreshToken,
|
|
2996
|
+
sandboxParams,
|
|
2915
2997
|
language,
|
|
2916
2998
|
applicationId,
|
|
2999
|
+
ledgerBaseUrl,
|
|
2917
3000
|
validateAgainst,
|
|
2918
3001
|
includeFullyConsentedData
|
|
2919
3002
|
// Removed onError and isRefreshingToken from dependencies to prevent duplicate API calls
|
|
@@ -3028,7 +3111,8 @@ var RedactoNoticeConsent = ({
|
|
|
3028
3111
|
meta_data: applicationId ? { specific_uuid: applicationId } : void 0,
|
|
3029
3112
|
guardianVerificationReference: verificationReference || void 0,
|
|
3030
3113
|
selfDeclaredAdult: selfDeclaredAdult || void 0,
|
|
3031
|
-
signal: submitController.signal
|
|
3114
|
+
signal: submitController.signal,
|
|
3115
|
+
...sandboxParams
|
|
3032
3116
|
});
|
|
3033
3117
|
}
|
|
3034
3118
|
onAccept == null ? void 0 : onAccept();
|
|
@@ -3211,7 +3295,7 @@ var RedactoNoticeConsent = ({
|
|
|
3211
3295
|
} finally {
|
|
3212
3296
|
setIsSubmittingGuardian(false);
|
|
3213
3297
|
}
|
|
3214
|
-
}, [accessToken, baseUrl, guardianFormData, digilockerMode, digilockerCallbackUrl, selectedPurposes, selectedDataElements, noticeId, onError]);
|
|
3298
|
+
}, [accessToken, sandboxParams, baseUrl, guardianFormData, digilockerMode, digilockerCallbackUrl, selectedPurposes, selectedDataElements, noticeId, onError]);
|
|
3215
3299
|
const handleAgeVerificationYes = (0, import_react2.useCallback)(() => {
|
|
3216
3300
|
setShowAgeVerification(false);
|
|
3217
3301
|
setIsMinorFlow(false);
|
|
@@ -3268,7 +3352,7 @@ var RedactoNoticeConsent = ({
|
|
|
3268
3352
|
setIsPollingStatus(false);
|
|
3269
3353
|
isPollingStatusRef.current = false;
|
|
3270
3354
|
setIsInitiatingVerification(false);
|
|
3271
|
-
}, [accessToken, baseUrl]);
|
|
3355
|
+
}, [accessToken, sandboxParams, baseUrl]);
|
|
3272
3356
|
const startPopupMonitoring = (0, import_react2.useCallback)((popup) => {
|
|
3273
3357
|
popupCheckIntervalRef.current = window.setInterval(() => {
|
|
3274
3358
|
if (popup.closed) {
|
|
@@ -3296,8 +3380,8 @@ var RedactoNoticeConsent = ({
|
|
|
3296
3380
|
[]
|
|
3297
3381
|
);
|
|
3298
3382
|
const startStatusPolling = (0, import_react2.useCallback)(
|
|
3299
|
-
(
|
|
3300
|
-
verificationSessionTokenRef.current =
|
|
3383
|
+
(token2) => {
|
|
3384
|
+
verificationSessionTokenRef.current = token2;
|
|
3301
3385
|
setIsPollingStatus(true);
|
|
3302
3386
|
isPollingStatusRef.current = true;
|
|
3303
3387
|
setVerificationError(null);
|
|
@@ -3349,7 +3433,7 @@ var RedactoNoticeConsent = ({
|
|
|
3349
3433
|
const response = await verifyGuardianStatus({
|
|
3350
3434
|
accessToken,
|
|
3351
3435
|
baseUrl,
|
|
3352
|
-
sessionToken:
|
|
3436
|
+
sessionToken: token2
|
|
3353
3437
|
});
|
|
3354
3438
|
consecutiveErrors = 0;
|
|
3355
3439
|
if (response.status === "verified") {
|
|
@@ -3419,7 +3503,7 @@ var RedactoNoticeConsent = ({
|
|
|
3419
3503
|
};
|
|
3420
3504
|
statusPollIntervalRef.current = window.setTimeout(poll, POLL_INTERVAL);
|
|
3421
3505
|
},
|
|
3422
|
-
[accessToken, baseUrl, getVerificationErrorMessage]
|
|
3506
|
+
[accessToken, sandboxParams, baseUrl, getVerificationErrorMessage]
|
|
3423
3507
|
);
|
|
3424
3508
|
const handleBackToGuardianForm = (0, import_react2.useCallback)((clearName = false) => {
|
|
3425
3509
|
var _a2, _b2;
|
|
@@ -3759,9 +3843,11 @@ var RedactoNoticeConsent = ({
|
|
|
3759
3843
|
fetchTTSAudioUrls({
|
|
3760
3844
|
accessToken,
|
|
3761
3845
|
baseUrl,
|
|
3846
|
+
ledgerBaseUrl,
|
|
3762
3847
|
noticeUuid: content.notice_uuid,
|
|
3763
3848
|
language: languageCode,
|
|
3764
|
-
signal: ttsAbortController.signal
|
|
3849
|
+
signal: ttsAbortController.signal,
|
|
3850
|
+
...sandboxParams
|
|
3765
3851
|
}).then((response) => {
|
|
3766
3852
|
setTtsAudioUrls(response.detail);
|
|
3767
3853
|
setIsTTSAvailable(true);
|
|
@@ -3774,7 +3860,7 @@ var RedactoNoticeConsent = ({
|
|
|
3774
3860
|
return () => {
|
|
3775
3861
|
ttsAbortController.abort();
|
|
3776
3862
|
};
|
|
3777
|
-
}, [content, selectedLanguage, accessToken, baseUrl, getLanguageCode]);
|
|
3863
|
+
}, [content, selectedLanguage, accessToken, sandboxParams, baseUrl, ledgerBaseUrl, getLanguageCode]);
|
|
3778
3864
|
const modalStyle = {
|
|
3779
3865
|
borderRadius: (settings == null ? void 0 : settings.borderRadius) || "8px",
|
|
3780
3866
|
backgroundColor: (settings == null ? void 0 : settings.backgroundColor) || "#ffffff"
|
|
@@ -4748,12 +4834,16 @@ var fetchConsentContent2 = async ({
|
|
|
4748
4834
|
org_uuid,
|
|
4749
4835
|
workspace_uuid,
|
|
4750
4836
|
notice_uuid,
|
|
4837
|
+
accessToken,
|
|
4751
4838
|
baseUrl,
|
|
4752
|
-
|
|
4839
|
+
language,
|
|
4840
|
+
specific_uuid,
|
|
4841
|
+
signal
|
|
4753
4842
|
}) => {
|
|
4754
4843
|
const apiBaseUrl = baseUrl || BASE_URL2;
|
|
4844
|
+
const noticesUrl = `${apiBaseUrl}/public/organisations/${org_uuid}/workspaces/${workspace_uuid}/notices`;
|
|
4755
4845
|
const url = new URL(
|
|
4756
|
-
`${
|
|
4846
|
+
accessToken ? `${noticesUrl}/${notice_uuid}` : `${noticesUrl}/get-notice/${notice_uuid}`
|
|
4757
4847
|
);
|
|
4758
4848
|
if (specific_uuid) {
|
|
4759
4849
|
url.searchParams.append("specific_uuid", specific_uuid);
|
|
@@ -4761,8 +4851,11 @@ var fetchConsentContent2 = async ({
|
|
|
4761
4851
|
const response = await fetch(url.toString(), {
|
|
4762
4852
|
method: "GET",
|
|
4763
4853
|
headers: {
|
|
4764
|
-
"Content-Type": "application/json"
|
|
4765
|
-
|
|
4854
|
+
"Content-Type": "application/json",
|
|
4855
|
+
"Accept-Language": language || "en",
|
|
4856
|
+
...accessToken ? { Authorization: `Bearer ${accessToken}` } : {}
|
|
4857
|
+
},
|
|
4858
|
+
signal
|
|
4766
4859
|
});
|
|
4767
4860
|
if (!response.ok) {
|
|
4768
4861
|
throw await parseApiError(
|
|
@@ -5252,6 +5345,9 @@ var RedactoConsentInlineComponent = ({
|
|
|
5252
5345
|
const [selectedPurposes, setSelectedPurposes] = (0, import_react4.useState)({});
|
|
5253
5346
|
const [selectedDataElements, setSelectedDataElements] = (0, import_react4.useState)({});
|
|
5254
5347
|
const [hasAlreadyConsented, setHasAlreadyConsented] = (0, import_react4.useState)(false);
|
|
5348
|
+
const [isCheckingConsent, setIsCheckingConsent] = (0, import_react4.useState)(
|
|
5349
|
+
Boolean(ledgerBaseUrl) && !applicationId
|
|
5350
|
+
);
|
|
5255
5351
|
const [fetchError, setFetchError] = (0, import_react4.useState)(null);
|
|
5256
5352
|
const [errorMessage, setErrorMessage] = (0, import_react4.useState)(null);
|
|
5257
5353
|
const hasSubmittedRef = (0, import_react4.useRef)(false);
|
|
@@ -5333,18 +5429,24 @@ var RedactoConsentInlineComponent = ({
|
|
|
5333
5429
|
}
|
|
5334
5430
|
return defaultText;
|
|
5335
5431
|
};
|
|
5336
|
-
const fetchNotice = async () => {
|
|
5432
|
+
const fetchNotice = async (signal) => {
|
|
5337
5433
|
setIsLoading(true);
|
|
5338
5434
|
setFetchError(null);
|
|
5435
|
+
setHasAlreadyConsented(false);
|
|
5339
5436
|
try {
|
|
5340
5437
|
const consentContentData = await fetchConsentContent2({
|
|
5341
5438
|
org_uuid,
|
|
5342
5439
|
workspace_uuid,
|
|
5343
5440
|
notice_uuid,
|
|
5441
|
+
accessToken,
|
|
5344
5442
|
baseUrl,
|
|
5345
5443
|
language,
|
|
5346
|
-
specific_uuid: applicationId
|
|
5444
|
+
specific_uuid: applicationId,
|
|
5445
|
+
signal
|
|
5347
5446
|
});
|
|
5447
|
+
if (signal == null ? void 0 : signal.aborted) {
|
|
5448
|
+
return;
|
|
5449
|
+
}
|
|
5348
5450
|
const activeConfig = consentContentData.detail.active_config;
|
|
5349
5451
|
setContent(activeConfig);
|
|
5350
5452
|
if (activeConfig.default_language) {
|
|
@@ -5380,6 +5482,9 @@ var RedactoConsentInlineComponent = ({
|
|
|
5380
5482
|
);
|
|
5381
5483
|
setSelectedPurposes(initialPurposeState);
|
|
5382
5484
|
} catch (err) {
|
|
5485
|
+
if ((signal == null ? void 0 : signal.aborted) || err instanceof Error && err.name === "AbortError") {
|
|
5486
|
+
return;
|
|
5487
|
+
}
|
|
5383
5488
|
const error = err;
|
|
5384
5489
|
setFetchError(error);
|
|
5385
5490
|
if (error.status === 409) {
|
|
@@ -5388,12 +5493,50 @@ var RedactoConsentInlineComponent = ({
|
|
|
5388
5493
|
onError == null ? void 0 : onError(error);
|
|
5389
5494
|
}
|
|
5390
5495
|
} finally {
|
|
5391
|
-
|
|
5496
|
+
if (!(signal == null ? void 0 : signal.aborted)) {
|
|
5497
|
+
setIsLoading(false);
|
|
5498
|
+
}
|
|
5392
5499
|
}
|
|
5393
5500
|
};
|
|
5394
5501
|
(0, import_react4.useEffect)(() => {
|
|
5395
|
-
|
|
5396
|
-
|
|
5502
|
+
const controller = new AbortController();
|
|
5503
|
+
void fetchNotice(controller.signal);
|
|
5504
|
+
return () => {
|
|
5505
|
+
controller.abort();
|
|
5506
|
+
};
|
|
5507
|
+
}, [org_uuid, workspace_uuid, notice_uuid, language, applicationId, accessToken]);
|
|
5508
|
+
(0, import_react4.useEffect)(() => {
|
|
5509
|
+
if (!ledgerBaseUrl || applicationId) {
|
|
5510
|
+
return;
|
|
5511
|
+
}
|
|
5512
|
+
if (!accessToken || !content) {
|
|
5513
|
+
return;
|
|
5514
|
+
}
|
|
5515
|
+
let active = true;
|
|
5516
|
+
const controller = new AbortController();
|
|
5517
|
+
const checkLedgerConsent = async () => {
|
|
5518
|
+
try {
|
|
5519
|
+
const ledgerStatus = await fetchNoticeConsentStatus({
|
|
5520
|
+
accessToken,
|
|
5521
|
+
ledgerBaseUrl,
|
|
5522
|
+
noticeUuid: notice_uuid,
|
|
5523
|
+
signal: controller.signal
|
|
5524
|
+
});
|
|
5525
|
+
if (active && ledgerStatus && isNoticeFullyConsented(ledgerStatus)) {
|
|
5526
|
+
setHasAlreadyConsented(true);
|
|
5527
|
+
}
|
|
5528
|
+
} finally {
|
|
5529
|
+
if (active) {
|
|
5530
|
+
setIsCheckingConsent(false);
|
|
5531
|
+
}
|
|
5532
|
+
}
|
|
5533
|
+
};
|
|
5534
|
+
checkLedgerConsent();
|
|
5535
|
+
return () => {
|
|
5536
|
+
active = false;
|
|
5537
|
+
controller.abort();
|
|
5538
|
+
};
|
|
5539
|
+
}, [ledgerBaseUrl, applicationId, accessToken, content, notice_uuid]);
|
|
5397
5540
|
const togglePurposeCollapse = (purposeUuid) => {
|
|
5398
5541
|
setCollapsedPurposes((prev) => ({
|
|
5399
5542
|
...prev,
|
|
@@ -5517,7 +5660,7 @@ var RedactoConsentInlineComponent = ({
|
|
|
5517
5660
|
]
|
|
5518
5661
|
);
|
|
5519
5662
|
(0, import_react4.useEffect)(() => {
|
|
5520
|
-
if (accessToken && content && areAllRequiredElementsChecked && !isSubmitting && !hasSubmittedRef.current) {
|
|
5663
|
+
if (accessToken && content && areAllRequiredElementsChecked && !isSubmitting && !isCheckingConsent && !hasAlreadyConsented && !hasSubmittedRef.current) {
|
|
5521
5664
|
hasSubmittedRef.current = true;
|
|
5522
5665
|
const autoSubmit = async () => {
|
|
5523
5666
|
try {
|
|
@@ -5534,6 +5677,8 @@ var RedactoConsentInlineComponent = ({
|
|
|
5534
5677
|
content,
|
|
5535
5678
|
areAllRequiredElementsChecked,
|
|
5536
5679
|
isSubmitting,
|
|
5680
|
+
isCheckingConsent,
|
|
5681
|
+
hasAlreadyConsented,
|
|
5537
5682
|
handleAcceptWithToken
|
|
5538
5683
|
]);
|
|
5539
5684
|
(0, import_react4.useEffect)(() => {
|
|
@@ -6794,6 +6939,7 @@ var submitAssistedConsent = async ({
|
|
|
6794
6939
|
organisationUuid,
|
|
6795
6940
|
workspaceUuid,
|
|
6796
6941
|
baseUrl,
|
|
6942
|
+
ledgerBaseUrl,
|
|
6797
6943
|
noticeUuid,
|
|
6798
6944
|
purposes,
|
|
6799
6945
|
language,
|
|
@@ -6824,7 +6970,7 @@ var submitAssistedConsent = async ({
|
|
|
6824
6970
|
declined: false,
|
|
6825
6971
|
language: language || void 0
|
|
6826
6972
|
};
|
|
6827
|
-
const url = `${publicScope(baseUrl, organisationUuid, workspaceUuid)}/submit-consent`;
|
|
6973
|
+
const url = `${publicScope(ledgerBaseUrl || baseUrl, organisationUuid, workspaceUuid)}/submit-consent`;
|
|
6828
6974
|
const response = await fetch(url, {
|
|
6829
6975
|
method: "POST",
|
|
6830
6976
|
headers: {
|
|
@@ -7951,57 +8097,6 @@ var as = {
|
|
|
7951
8097
|
tryAgain: "\u0985\u09A8\u09C1\u0997\u09CD\u09F0\u09B9 \u0995\u09F0\u09BF \u09AA\u09C1\u09A8\u09F0 \u099A\u09C7\u09B7\u09CD\u099F\u09BE \u0995\u09F0\u0995\u0964",
|
|
7952
8098
|
close: "\u09AC\u09A8\u09CD\u09A7 \u0995\u09F0\u0995"
|
|
7953
8099
|
};
|
|
7954
|
-
var bho = {
|
|
7955
|
-
useEmailInstead: "\u0908\u092E\u0947\u0932 \u0907\u0938\u094D\u0924\u0947\u092E\u093E\u0932 \u0915\u0930\u0940\u0902",
|
|
7956
|
-
useMobileInstead: "\u092E\u094B\u092C\u093E\u0907\u0932 \u0907\u0938\u094D\u0924\u0947\u092E\u093E\u0932 \u0915\u0930\u0940\u0902",
|
|
7957
|
-
emailAddress: "\u0908\u092E\u0947\u0932 \u092A\u0924\u093E",
|
|
7958
|
-
otpHelperEmail: "\u0939\u092E\u0928\u0940 \u090F\u0939 \u0908\u092E\u0947\u0932 \u092A\u0930 \u090F\u0915 \u092C\u0947\u0930 \u0907\u0938\u094D\u0924\u0947\u092E\u093E\u0932 \u0939\u094B\u0916\u0947 \u0935\u093E\u0932\u093E \u092A\u093E\u0938\u0935\u0930\u094D\u0921 \u092D\u0947\u091C\u092C\u0964",
|
|
7959
|
-
changeEmail: "\u0908\u092E\u0947\u0932 \u092C\u0926\u0932\u0940\u0902",
|
|
7960
|
-
expandDetails: "{name} \u0915\u0947 \u0935\u093F\u0935\u0930\u0923 \u092B\u0948\u0932\u093E\u0908\u0902",
|
|
7961
|
-
collapseDetails: "{name} \u0915\u0947 \u0935\u093F\u0935\u0930\u0923 \u0938\u092E\u0947\u091F\u0940\u0902",
|
|
7962
|
-
selectAllFor: "{name} \u0916\u093E\u0924\u093F\u0930 \u0938\u092D \u0921\u0947\u091F\u093E \u0924\u0924\u094D\u0935 \u091A\u0941\u0928\u0940\u0902",
|
|
7963
|
-
selectElement: "{name} \u091A\u0941\u0928\u0940\u0902",
|
|
7964
|
-
selectElementRequired: "{name} \u091A\u0941\u0928\u0940\u0902 (\u091C\u0930\u0942\u0930\u0940)",
|
|
7965
|
-
required: "\u091C\u0930\u0942\u0930\u0940",
|
|
7966
|
-
logoAlt: "\u0932\u094B\u0917\u094B",
|
|
7967
|
-
selectLanguage: "\u092D\u093E\u0937\u093E \u091A\u0941\u0928\u0940\u0902",
|
|
7968
|
-
selectLanguageCurrent: "\u092D\u093E\u0937\u093E \u091A\u0941\u0928\u0940\u0902. \u092E\u094C\u091C\u0942\u0926\u093E \u092D\u093E\u0937\u093E: {lang}",
|
|
7969
|
-
opensInNewTab: "\u0928\u092F\u093E \u091F\u0948\u092C \u092E\u0947\u0902 \u0916\u0941\u0932\u0947\u0932\u093E",
|
|
7970
|
-
audioStart: "\u0911\u0921\u093F\u092F\u094B \u092A\u094D\u0932\u0947\u092C\u0948\u0915 \u0936\u0941\u0930\u0942 \u0915\u0930\u0940\u0902",
|
|
7971
|
-
audioPause: "\u0911\u0921\u093F\u092F\u094B \u092A\u094D\u0932\u0947\u092C\u0948\u0915 \u0930\u094B\u0915\u0940\u0902",
|
|
7972
|
-
talkbackStart: "\u091F\u0949\u0915\u092C\u0948\u0915 \u0936\u0941\u0930\u0942 \u0915\u0930\u0940\u0902",
|
|
7973
|
-
talkbackPause: "\u091F\u0949\u0915\u092C\u0948\u0915 \u0930\u094B\u0915\u0940\u0902",
|
|
7974
|
-
mobileNumber: "\u092E\u094B\u092C\u093E\u0907\u0932 \u0928\u0902\u092C\u0930",
|
|
7975
|
-
otpHelper: "\u0939\u092E\u0928\u0940 \u090F\u0939 \u0928\u0902\u092C\u0930 \u092A\u0930 \u090F\u0915 \u092C\u0947\u0930 \u0907\u0938\u094D\u0924\u0947\u092E\u093E\u0932 \u0939\u094B\u0916\u0947 \u0935\u093E\u0932\u093E \u092A\u093E\u0938\u0935\u0930\u094D\u0921 \u092D\u0947\u091C\u092C\u0964",
|
|
7976
|
-
otpSentTo: "\u0913\u091F\u0940\u092A\u0940 (OTP) \u092D\u0947\u091C\u0932 \u0917\u0907\u0932",
|
|
7977
|
-
changeMobile: "\u092E\u094B\u092C\u093E\u0907\u0932 \u0928\u0902\u092C\u0930 \u092C\u0926\u0932\u0940\u0902",
|
|
7978
|
-
enterNDigitOtp: "{count}-\u0905\u0902\u0915 \u0915\u0947 \u0913\u091F\u0940\u092A\u0940 (OTP) \u0921\u093E\u0932\u0940\u0902",
|
|
7979
|
-
otpDigit: "\u0913\u091F\u0940\u092A\u0940 (OTP) \u0905\u0902\u0915 {index}",
|
|
7980
|
-
resendIn: "{seconds} \u0938\u0947\u0915\u0902\u0921 \u092E\u0947\u0902 \u0913\u091F\u0940\u092A\u0940 (OTP) \u092B\u0947\u0930 \u0938\u0947 \u092D\u0947\u091C\u0940\u0902",
|
|
7981
|
-
sending: "\u092D\u0947\u091C\u0932 \u091C\u093E \u0930\u0939\u0932 \u092C\u093E\u2026",
|
|
7982
|
-
resendOtp: "\u0913\u091F\u0940\u092A\u0940 (OTP) \u092B\u0947\u0930 \u0938\u0947 \u092D\u0947\u091C\u0940\u0902",
|
|
7983
|
-
getOtp: "\u0913\u091F\u0940\u092A\u0940 (OTP) \u092A\u093E\u0908\u0902",
|
|
7984
|
-
verifying: "\u0938\u0924\u094D\u092F\u093E\u092A\u093F\u0924 \u0915\u0907\u0932 \u091C\u093E \u0930\u0939\u0932 \u092C\u093E\u2026",
|
|
7985
|
-
verifyOtp: "\u0913\u091F\u0940\u092A\u0940 (OTP) \u0938\u0924\u094D\u092F\u093E\u092A\u093F\u0924 \u0915\u0930\u0940\u0902",
|
|
7986
|
-
sendOtp: "\u0913\u091F\u0940\u092A\u0940 (OTP) \u092D\u0947\u091C\u0940\u0902",
|
|
7987
|
-
confirmOtp: "\u0913\u091F\u0940\u092A\u0940 (OTP) \u0915\u0947 \u092A\u0941\u0937\u094D\u091F\u093F \u0915\u0930\u0940\u0902",
|
|
7988
|
-
verifyWithOtp: "\u0913\u091F\u0940\u092A\u0940 (OTP) \u0938\u0947 \u0938\u0924\u094D\u092F\u093E\u092A\u093F\u0924 \u0915\u0930\u0940\u0902",
|
|
7989
|
-
editSelections: "\u091A\u0941\u0928\u093E\u0935 \u092E\u0947\u0902 \u092C\u0926\u0932\u093E\u0935 \u0915\u0930\u0940\u0902",
|
|
7990
|
-
otpIncorrect: "\u0930\u0909\u0930\u093E \u0921\u093E\u0932\u0932 \u0938\u0924\u094D\u092F\u093E\u092A\u0928 \u0915\u094B\u0921 \u0917\u0932\u0924 \u092C\u093E\u0964 \u0915\u0943\u092A\u092F\u093E \u091C\u093E\u0901\u091A \u0915\u0930\u0940\u0902 \u0906 \u092B\u0947\u0930 \u0938\u0947 \u0915\u094B\u0936\u093F\u0936 \u0915\u0930\u0940\u0902\u0964",
|
|
7991
|
-
otpExpired: "\u0930\u0909\u0930\u093E \u0938\u0924\u094D\u092F\u093E\u092A\u0928 \u0915\u094B\u0921 \u0915\u0947 \u092E\u093F\u092F\u093E\u0926 \u0916\u0924\u092E \u0939\u094B \u0917\u0907\u0932 \u092C\u093E\u0964 \u0915\u0943\u092A\u092F\u093E \u0928\u092F\u093E \u0915\u094B\u0921 \u092E\u093E\u0902\u0917\u0940\u0902\u0964",
|
|
7992
|
-
otpNotFound: "\u0938\u0924\u094D\u092F\u093E\u092A\u0928 \u0915\u094B\u0921 \u0928\u093E \u092E\u093F\u0932\u0932\u0964 \u0915\u0943\u092A\u092F\u093E \u0928\u092F\u093E \u0915\u094B\u0921 \u092E\u093E\u0902\u0917\u0940\u0902\u0964",
|
|
7993
|
-
otpVerifyFailed: "\u0913\u091F\u0940\u092A\u0940 (OTP) \u0915\u0947 \u0938\u0924\u094D\u092F\u093E\u092A\u0928 \u0928\u093E \u0939\u094B \u0938\u0915\u0932\u0964 \u0915\u0943\u092A\u092F\u093E \u092B\u0947\u0930 \u0938\u0947 \u0915\u094B\u0936\u093F\u0936 \u0915\u0930\u0940\u0902\u0964",
|
|
7994
|
-
otpSendFailed: "\u0913\u091F\u0940\u092A\u0940 (OTP) \u0928\u093E \u092D\u0947\u091C\u0932 \u091C\u093E \u0938\u0915\u0932\u0964 \u0915\u0943\u092A\u092F\u093E \u092B\u0947\u0930 \u0938\u0947 \u0915\u094B\u0936\u093F\u0936 \u0915\u0930\u0940\u0902\u0964",
|
|
7995
|
-
consentConfirmed: "\u0938\u0939\u092E\u0924\u093F \u0915\u0947 \u092A\u0941\u0937\u094D\u091F\u093F \u092D\u0907\u0932",
|
|
7996
|
-
recordedUnder: "\u0913\u091F\u0940\u092A\u0940 (OTP) \u0938\u0924\u094D\u092F\u093E\u092A\u093F\u0924 \xB7 {regulation} \u0915\u0947 \u0924\u0939\u0924 \u0926\u0930\u094D\u091C \u092D\u0907\u0932",
|
|
7997
|
-
recordedUnderAt: "\u0913\u091F\u0940\u092A\u0940 (OTP) \u0938\u0924\u094D\u092F\u093E\u092A\u093F\u0924 \xB7 {regulation} \u0915\u0947 \u0924\u0939\u0924 {time} \u092C\u091C\u0947 \u0926\u0930\u094D\u091C \u092D\u0907\u0932",
|
|
7998
|
-
consentReferenceId: "\u0938\u0939\u092E\u0924\u093F \u0938\u0902\u0926\u0930\u094D\u092D \u0906\u0908\u0921\u0940",
|
|
7999
|
-
proceed: "\u0906\u0917\u0947 \u092C\u0922\u093C\u0940\u0902",
|
|
8000
|
-
loadingNotice: "\u0928\u094B\u091F\u093F\u0938 \u0932\u094B\u0921 \u0939\u094B \u0930\u0939\u0932 \u092C\u093E",
|
|
8001
|
-
loadFailedTitle: "\u0938\u0939\u092E\u0924\u093F \u0928\u094B\u091F\u093F\u0938 \u0932\u094B\u0921 \u0928\u093E \u0939\u094B \u0938\u0915\u0932",
|
|
8002
|
-
tryAgain: "\u0915\u0943\u092A\u092F\u093E \u092B\u0947\u0930 \u0938\u0947 \u0915\u094B\u0938\u093F\u0938 \u0915\u0930\u0940\u0902\u0964",
|
|
8003
|
-
close: "\u092C\u0902\u0926 \u0915\u0930\u0940\u0902"
|
|
8004
|
-
};
|
|
8005
8100
|
var brx = {
|
|
8006
8101
|
useEmailInstead: "\u0907\u092E\u0947\u0932 \u092C\u093E\u0939\u093E\u092F",
|
|
8007
8102
|
useMobileInstead: "\u092E\u092C\u093E\u0907\u0932 \u092C\u093E\u0939\u093E\u092F",
|
|
@@ -8126,7 +8221,6 @@ var STATIC_STRINGS = {
|
|
|
8126
8221
|
te,
|
|
8127
8222
|
ur,
|
|
8128
8223
|
as,
|
|
8129
|
-
bho,
|
|
8130
8224
|
brx,
|
|
8131
8225
|
doi
|
|
8132
8226
|
};
|
|
@@ -8311,6 +8405,7 @@ var RedactoNoticeAssisted = ({
|
|
|
8311
8405
|
workspaceUuid,
|
|
8312
8406
|
noticeUuid,
|
|
8313
8407
|
baseUrl,
|
|
8408
|
+
ledgerBaseUrl,
|
|
8314
8409
|
onDecline,
|
|
8315
8410
|
onComplete
|
|
8316
8411
|
}) => {
|
|
@@ -9046,6 +9141,19 @@ var RedactoNoticeAssisted = ({
|
|
|
9046
9141
|
return;
|
|
9047
9142
|
}
|
|
9048
9143
|
const token = verifyDetail.access_token;
|
|
9144
|
+
if (ledgerBaseUrl) {
|
|
9145
|
+
const ledgerStatus = await fetchNoticeConsentStatusForScope({
|
|
9146
|
+
accessToken: token,
|
|
9147
|
+
ledgerBaseUrl,
|
|
9148
|
+
organisationUuid,
|
|
9149
|
+
workspaceUuid,
|
|
9150
|
+
noticeUuid: content.notice_uuid
|
|
9151
|
+
});
|
|
9152
|
+
if (ledgerStatus && isNoticeFullyConsented(ledgerStatus)) {
|
|
9153
|
+
handleSuccess();
|
|
9154
|
+
return;
|
|
9155
|
+
}
|
|
9156
|
+
}
|
|
9049
9157
|
const submitPurposes = content.purposes.map((purpose) => ({
|
|
9050
9158
|
...purpose,
|
|
9051
9159
|
selected: selectedPurposes[purpose.uuid] || false,
|
|
@@ -9059,6 +9167,7 @@ var RedactoNoticeAssisted = ({
|
|
|
9059
9167
|
organisationUuid,
|
|
9060
9168
|
workspaceUuid,
|
|
9061
9169
|
baseUrl,
|
|
9170
|
+
ledgerBaseUrl,
|
|
9062
9171
|
noticeUuid: content.notice_uuid,
|
|
9063
9172
|
purposes: submitPurposes,
|
|
9064
9173
|
language: toBcp47Code(selectedLanguage)
|
|
@@ -9082,6 +9191,7 @@ var RedactoNoticeAssisted = ({
|
|
|
9082
9191
|
otpUuid,
|
|
9083
9192
|
otpValue,
|
|
9084
9193
|
baseUrl,
|
|
9194
|
+
ledgerBaseUrl,
|
|
9085
9195
|
selectedPurposes,
|
|
9086
9196
|
selectedDataElements,
|
|
9087
9197
|
selectedLanguage,
|