@redacto.io/consent-sdk-react-native 5.0.0-beta.1 → 5.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/README.md +75 -0
- package/dist/chunk-B2TXWC2C.mjs +60 -0
- package/dist/index.d.mts +28 -2
- package/dist/index.d.ts +28 -2
- package/dist/index.js +239 -190
- package/dist/index.mjs +196 -191
- package/dist/privacy-center.d.mts +147 -63
- package/dist/privacy-center.d.ts +147 -63
- package/dist/privacy-center.js +1614 -713
- package/dist/privacy-center.mjs +1551 -687
- package/package.json +10 -9
- package/LICENSE +0 -176
- package/dist/chunk-Y6FXYEAI.mjs +0 -10
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
SANDBOX_TOKEN_HEADER,
|
|
3
|
+
toLanguageCode
|
|
4
|
+
} from "./chunk-B2TXWC2C.mjs";
|
|
2
5
|
|
|
3
6
|
// src/RedactoNoticeConsent/RedactoNoticeConsent.tsx
|
|
4
7
|
import {
|
|
@@ -27,6 +30,64 @@ import Svg3, { Path as Path3, Rect, SvgUri } from "react-native-svg";
|
|
|
27
30
|
// src/RedactoNoticeConsent/api/index.ts
|
|
28
31
|
import { jwtDecode } from "jwt-decode";
|
|
29
32
|
|
|
33
|
+
// src/RedactoNoticeConsent/api/sandbox.ts
|
|
34
|
+
var resolveSandboxAuth = (params) => {
|
|
35
|
+
var _a, _b, _c, _d, _e;
|
|
36
|
+
const token = (_a = params.token) == null ? void 0 : _a.trim();
|
|
37
|
+
if (!token) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
const organisationUuid = (_b = params.organisationUuid) == null ? void 0 : _b.trim();
|
|
41
|
+
const workspaceUuid = (_c = params.workspaceUuid) == null ? void 0 : _c.trim();
|
|
42
|
+
const ucic = (_d = params.sandboxUcic) == null ? void 0 : _d.trim();
|
|
43
|
+
const subject = (_e = params.sandboxSubject) == null ? void 0 : _e.trim();
|
|
44
|
+
if (!organisationUuid || !workspaceUuid) {
|
|
45
|
+
throw new Error(
|
|
46
|
+
"Sandbox mode requires organisationUuid and workspaceUuid props"
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
if (!ucic && !subject) {
|
|
50
|
+
throw new Error("Sandbox mode requires a UCIC, email, or mobile");
|
|
51
|
+
}
|
|
52
|
+
return { token, ucic, subject: subject != null ? subject : "", organisationUuid, workspaceUuid };
|
|
53
|
+
};
|
|
54
|
+
var resolveRequestAuth = (accessToken, sandboxParams, decodeTokenSafely2) => {
|
|
55
|
+
const sandbox = resolveSandboxAuth(sandboxParams);
|
|
56
|
+
if (sandbox) {
|
|
57
|
+
return {
|
|
58
|
+
organisationUuid: sandbox.organisationUuid,
|
|
59
|
+
workspaceUuid: sandbox.workspaceUuid,
|
|
60
|
+
sandbox
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const decodedToken = accessToken ? decodeTokenSafely2(accessToken) : null;
|
|
64
|
+
if (!decodedToken) {
|
|
65
|
+
throw new Error("Invalid access token");
|
|
66
|
+
}
|
|
67
|
+
const { organisation_uuid, workspace_uuid } = decodedToken;
|
|
68
|
+
if (!organisation_uuid || !workspace_uuid) {
|
|
69
|
+
throw new Error("Invalid token: missing organization or workspace UUID");
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
organisationUuid: organisation_uuid,
|
|
73
|
+
workspaceUuid: workspace_uuid,
|
|
74
|
+
sandbox: null
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
var buildAuthHeaders = (accessToken, sandbox) => {
|
|
78
|
+
if (sandbox) {
|
|
79
|
+
return { [SANDBOX_TOKEN_HEADER]: sandbox.token };
|
|
80
|
+
}
|
|
81
|
+
return { Authorization: `Bearer ${accessToken}` };
|
|
82
|
+
};
|
|
83
|
+
var sandboxBodyIdentity = (sandbox) => {
|
|
84
|
+
if (sandbox.ucic) {
|
|
85
|
+
return { org_user_id: sandbox.ucic };
|
|
86
|
+
}
|
|
87
|
+
return sandbox.subject.includes("@") ? { primary_email: sandbox.subject } : { primary_mobile: sandbox.subject };
|
|
88
|
+
};
|
|
89
|
+
var sandboxQueryIdentity = (sandbox) => sandboxBodyIdentity(sandbox);
|
|
90
|
+
|
|
30
91
|
// src/constants.ts
|
|
31
92
|
var DEFAULT_CONSENT_API_BASE_URL = "https://api.redacto.io/consent";
|
|
32
93
|
|
|
@@ -65,21 +126,19 @@ var fetchConsentContent = async ({
|
|
|
65
126
|
specific_uuid,
|
|
66
127
|
validate_against = "all",
|
|
67
128
|
include_fully_consented_data = false,
|
|
68
|
-
signal
|
|
129
|
+
signal,
|
|
130
|
+
...sandboxParams
|
|
69
131
|
}) => {
|
|
70
|
-
if (!noticeId || !
|
|
71
|
-
throw new Error("noticeId
|
|
132
|
+
if (!noticeId || !validate_against) {
|
|
133
|
+
throw new Error("noticeId is required");
|
|
72
134
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
throw new Error("Invalid access token");
|
|
76
|
-
}
|
|
77
|
-
const { organisation_uuid: ORGANISATION_UUID, workspace_uuid: WORKSPACE_UUID } = decodedToken;
|
|
78
|
-
if (!ORGANISATION_UUID || !WORKSPACE_UUID) {
|
|
79
|
-
throw new Error("Invalid token: missing organization or workspace UUID");
|
|
135
|
+
if (!accessToken && !sandboxParams.token) {
|
|
136
|
+
throw new Error("accessToken or token is required");
|
|
80
137
|
}
|
|
138
|
+
const { organisationUuid: ORGANISATION_UUID, workspaceUuid: WORKSPACE_UUID, sandbox } = resolveRequestAuth(accessToken, sandboxParams, decodeTokenSafely);
|
|
81
139
|
const apiBaseUrl = baseUrl || DEFAULT_CONSENT_API_BASE_URL;
|
|
82
|
-
const
|
|
140
|
+
const cacheIdentity = sandbox ? `sandbox:${sandbox.organisationUuid}:${sandbox.workspaceUuid}:${sandbox.ucic || sandbox.subject}` : accessToken;
|
|
141
|
+
const cacheKey = `${cacheIdentity}-${noticeId}-${validate_against}-${language}-${specific_uuid || ""}-${include_fully_consented_data}`;
|
|
83
142
|
if (validate_against === "all" && !specific_uuid) {
|
|
84
143
|
const cachedData = getCachedData(cacheKey);
|
|
85
144
|
if (cachedData) {
|
|
@@ -96,10 +155,15 @@ var fetchConsentContent = async ({
|
|
|
96
155
|
if (include_fully_consented_data) {
|
|
97
156
|
url.searchParams.append("include_fully_consented_data", "true");
|
|
98
157
|
}
|
|
158
|
+
if (sandbox) {
|
|
159
|
+
for (const [key, value] of Object.entries(sandboxQueryIdentity(sandbox))) {
|
|
160
|
+
url.searchParams.append(key, value);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
99
163
|
const response = await fetch(url.toString(), {
|
|
100
164
|
method: "GET",
|
|
101
165
|
headers: {
|
|
102
|
-
|
|
166
|
+
...buildAuthHeaders(accessToken, sandbox),
|
|
103
167
|
"Accept-Language": language,
|
|
104
168
|
"Content-Type": "application/json"
|
|
105
169
|
},
|
|
@@ -138,20 +202,18 @@ var submitConsentEvent = async ({
|
|
|
138
202
|
meta_data,
|
|
139
203
|
guardianVerificationReference,
|
|
140
204
|
selfDeclaredAdult,
|
|
141
|
-
|
|
205
|
+
language,
|
|
206
|
+
signal,
|
|
207
|
+
...sandboxParams
|
|
142
208
|
}) => {
|
|
143
|
-
if (!noticeUuid || !
|
|
144
|
-
throw new Error("noticeUuid
|
|
145
|
-
}
|
|
146
|
-
const decodedToken = decodeTokenSafely(accessToken);
|
|
147
|
-
if (!decodedToken) {
|
|
148
|
-
throw new Error("Invalid access token");
|
|
209
|
+
if (!noticeUuid || !Array.isArray(purposes)) {
|
|
210
|
+
throw new Error("noticeUuid and purposes array are required");
|
|
149
211
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
throw new Error("Invalid token: missing organization or workspace UUID");
|
|
212
|
+
if (!accessToken && !sandboxParams.token) {
|
|
213
|
+
throw new Error("accessToken or token is required");
|
|
153
214
|
}
|
|
154
|
-
const
|
|
215
|
+
const { organisationUuid: ORGANISATION_UUID, workspaceUuid: WORKSPACE_UUID, sandbox } = resolveRequestAuth(accessToken, sandboxParams, decodeTokenSafely);
|
|
216
|
+
const apiBaseUrl = (sandbox ? null : ledgerBaseUrl) || baseUrl || DEFAULT_CONSENT_API_BASE_URL;
|
|
155
217
|
const validatedPurposes = purposes.map((purpose) => {
|
|
156
218
|
if (!purpose.uuid) {
|
|
157
219
|
throw new Error("Invalid purpose data: missing uuid");
|
|
@@ -174,17 +236,19 @@ var submitConsentEvent = async ({
|
|
|
174
236
|
declined: Boolean(declined),
|
|
175
237
|
meta_data: meta_data ? { specific_uuid: meta_data.specific_uuid } : void 0,
|
|
176
238
|
guardian_verification_reference: guardianVerificationReference,
|
|
177
|
-
self_declared_adult: selfDeclaredAdult
|
|
239
|
+
self_declared_adult: selfDeclaredAdult,
|
|
240
|
+
language: toLanguageCode(language)
|
|
178
241
|
};
|
|
242
|
+
const requestBody = sandbox ? { ...payload, ...sandboxBodyIdentity(sandbox) } : payload;
|
|
179
243
|
const response = await fetch(
|
|
180
244
|
`${apiBaseUrl}/public/organisations/${ORGANISATION_UUID}/workspaces/${WORKSPACE_UUID}/submit-consent`,
|
|
181
245
|
{
|
|
182
246
|
method: "POST",
|
|
183
247
|
headers: {
|
|
184
|
-
|
|
248
|
+
...buildAuthHeaders(accessToken, sandbox),
|
|
185
249
|
"Content-Type": "application/json"
|
|
186
250
|
},
|
|
187
|
-
body: JSON.stringify(
|
|
251
|
+
body: JSON.stringify(requestBody),
|
|
188
252
|
signal
|
|
189
253
|
}
|
|
190
254
|
);
|
|
@@ -210,28 +274,30 @@ var submitConsentEvent = async ({
|
|
|
210
274
|
var fetchTTSAudioUrls = async ({
|
|
211
275
|
accessToken,
|
|
212
276
|
baseUrl,
|
|
277
|
+
ledgerBaseUrl,
|
|
213
278
|
noticeUuid,
|
|
214
279
|
language,
|
|
215
|
-
signal
|
|
280
|
+
signal,
|
|
281
|
+
...sandboxParams
|
|
216
282
|
}) => {
|
|
217
|
-
if (!accessToken || !noticeUuid || !language) {
|
|
218
|
-
throw new Error("accessToken, noticeUuid, and language are required");
|
|
283
|
+
if (!accessToken && !sandboxParams.token || !noticeUuid || !language) {
|
|
284
|
+
throw new Error("accessToken (or token), noticeUuid, and language are required");
|
|
219
285
|
}
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
throw new Error("Invalid access token");
|
|
223
|
-
}
|
|
224
|
-
const { organisation_uuid: ORGANISATION_UUID, workspace_uuid: WORKSPACE_UUID } = decodedToken;
|
|
225
|
-
if (!ORGANISATION_UUID || !WORKSPACE_UUID) {
|
|
226
|
-
throw new Error("Invalid token: missing organization or workspace UUID");
|
|
227
|
-
}
|
|
228
|
-
const apiBaseUrl = baseUrl || DEFAULT_CONSENT_API_BASE_URL;
|
|
286
|
+
const { organisationUuid: ORGANISATION_UUID, workspaceUuid: WORKSPACE_UUID, sandbox } = resolveRequestAuth(accessToken, sandboxParams, decodeTokenSafely);
|
|
287
|
+
const apiBaseUrl = (sandbox ? null : ledgerBaseUrl) || baseUrl || DEFAULT_CONSENT_API_BASE_URL;
|
|
229
288
|
const normalizedLanguage = language === "en" || language === "EN" ? "English" : language;
|
|
230
|
-
const url =
|
|
231
|
-
|
|
289
|
+
const url = new URL(
|
|
290
|
+
`${apiBaseUrl}/public/organisations/${ORGANISATION_UUID}/workspaces/${WORKSPACE_UUID}/notices/${noticeUuid}/audio/${encodeURIComponent(normalizedLanguage)}`
|
|
291
|
+
);
|
|
292
|
+
if (sandbox) {
|
|
293
|
+
for (const [key, value] of Object.entries(sandboxQueryIdentity(sandbox))) {
|
|
294
|
+
url.searchParams.append(key, value);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
const response = await fetch(url.toString(), {
|
|
232
298
|
method: "GET",
|
|
233
299
|
headers: {
|
|
234
|
-
|
|
300
|
+
...buildAuthHeaders(accessToken, sandbox),
|
|
235
301
|
Accept: "application/json",
|
|
236
302
|
"Content-Type": "application/json"
|
|
237
303
|
},
|
|
@@ -400,122 +466,6 @@ var verifyGuardianStatus = async ({
|
|
|
400
466
|
};
|
|
401
467
|
};
|
|
402
468
|
|
|
403
|
-
// src/shared/notice-consent-status.ts
|
|
404
|
-
import { jwtDecode as jwtDecode2 } from "jwt-decode";
|
|
405
|
-
var decodeNoticeConsentToken = (token) => {
|
|
406
|
-
try {
|
|
407
|
-
return jwtDecode2(token);
|
|
408
|
-
} catch {
|
|
409
|
-
return null;
|
|
410
|
-
}
|
|
411
|
-
};
|
|
412
|
-
var fetchNoticeConsentStatusForScope = async ({
|
|
413
|
-
accessToken,
|
|
414
|
-
ledgerBaseUrl,
|
|
415
|
-
organisationUuid,
|
|
416
|
-
workspaceUuid,
|
|
417
|
-
noticeUuid,
|
|
418
|
-
signal
|
|
419
|
-
}) => {
|
|
420
|
-
if (!accessToken || !ledgerBaseUrl || !organisationUuid || !workspaceUuid || !noticeUuid) {
|
|
421
|
-
return null;
|
|
422
|
-
}
|
|
423
|
-
try {
|
|
424
|
-
const response = await fetch(
|
|
425
|
-
`${ledgerBaseUrl}/public/organisations/${organisationUuid}/workspaces/${workspaceUuid}/notices/${noticeUuid}/check-consent`,
|
|
426
|
-
{
|
|
427
|
-
method: "POST",
|
|
428
|
-
headers: {
|
|
429
|
-
Authorization: `Bearer ${accessToken}`,
|
|
430
|
-
"Content-Type": "application/json"
|
|
431
|
-
},
|
|
432
|
-
body: "{}",
|
|
433
|
-
signal
|
|
434
|
-
}
|
|
435
|
-
);
|
|
436
|
-
if (!response.ok) {
|
|
437
|
-
return null;
|
|
438
|
-
}
|
|
439
|
-
const data = await response.json();
|
|
440
|
-
const body = data && typeof data === "object" && "detail" in data && data.detail ? data.detail : data;
|
|
441
|
-
if (!body || !Array.isArray(body.purposes)) {
|
|
442
|
-
return null;
|
|
443
|
-
}
|
|
444
|
-
return body;
|
|
445
|
-
} catch {
|
|
446
|
-
return null;
|
|
447
|
-
}
|
|
448
|
-
};
|
|
449
|
-
var fetchNoticeConsentStatus = async ({
|
|
450
|
-
accessToken,
|
|
451
|
-
ledgerBaseUrl,
|
|
452
|
-
noticeUuid,
|
|
453
|
-
signal
|
|
454
|
-
}) => {
|
|
455
|
-
if (!accessToken || !ledgerBaseUrl || !noticeUuid) {
|
|
456
|
-
return null;
|
|
457
|
-
}
|
|
458
|
-
const decodedToken = decodeNoticeConsentToken(accessToken);
|
|
459
|
-
if (!decodedToken) {
|
|
460
|
-
return null;
|
|
461
|
-
}
|
|
462
|
-
const {
|
|
463
|
-
organisation_uuid: ORGANISATION_UUID,
|
|
464
|
-
workspace_uuid: WORKSPACE_UUID
|
|
465
|
-
} = decodedToken;
|
|
466
|
-
if (!ORGANISATION_UUID || !WORKSPACE_UUID) {
|
|
467
|
-
return null;
|
|
468
|
-
}
|
|
469
|
-
return fetchNoticeConsentStatusForScope({
|
|
470
|
-
accessToken,
|
|
471
|
-
ledgerBaseUrl,
|
|
472
|
-
organisationUuid: ORGANISATION_UUID,
|
|
473
|
-
workspaceUuid: WORKSPACE_UUID,
|
|
474
|
-
noticeUuid,
|
|
475
|
-
signal
|
|
476
|
-
});
|
|
477
|
-
};
|
|
478
|
-
var isNoticeFullyConsented = (status) => status.consented && status.all_mandatory_active;
|
|
479
|
-
var buildLedgerConsentOverlay = (status, configPurposes) => {
|
|
480
|
-
var _a, _b;
|
|
481
|
-
const byUuid = new Map(status.purposes.map((p) => [p.uuid, p]));
|
|
482
|
-
const hasHistory = status.purposes.some(
|
|
483
|
-
(p) => (p.status || "INACTIVE") !== "INACTIVE"
|
|
484
|
-
);
|
|
485
|
-
if (!hasHistory) {
|
|
486
|
-
return null;
|
|
487
|
-
}
|
|
488
|
-
const purpose_selections = {};
|
|
489
|
-
for (const cp of configPurposes) {
|
|
490
|
-
const lp = byUuid.get(cp.uuid);
|
|
491
|
-
const purposeStatus = (lp == null ? void 0 : lp.status) || "INACTIVE";
|
|
492
|
-
const selectedByUuid = new Map(
|
|
493
|
-
((lp == null ? void 0 : lp.data_elements) || []).map((de) => [de.uuid, de.selected])
|
|
494
|
-
);
|
|
495
|
-
const data_elements = {};
|
|
496
|
-
for (const de of cp.data_elements) {
|
|
497
|
-
data_elements[de.uuid] = {
|
|
498
|
-
selected: (_a = selectedByUuid.get(de.uuid)) != null ? _a : false,
|
|
499
|
-
enabled: de.enabled,
|
|
500
|
-
required: de.required
|
|
501
|
-
};
|
|
502
|
-
}
|
|
503
|
-
purpose_selections[cp.uuid] = {
|
|
504
|
-
selected: (_b = lp == null ? void 0 : lp.selected) != null ? _b : false,
|
|
505
|
-
status: purposeStatus,
|
|
506
|
-
needs_reconsent: purposeStatus !== "ACTIVE",
|
|
507
|
-
data_elements
|
|
508
|
-
};
|
|
509
|
-
}
|
|
510
|
-
const reconsent_required = configPurposes.some(
|
|
511
|
-
(cp) => {
|
|
512
|
-
var _a2;
|
|
513
|
-
return (((_a2 = purpose_selections[cp.uuid]) == null ? void 0 : _a2.status) || "INACTIVE") !== "ACTIVE";
|
|
514
|
-
}
|
|
515
|
-
);
|
|
516
|
-
return { reconsent_required, purpose_selections };
|
|
517
|
-
};
|
|
518
|
-
|
|
519
469
|
// src/RedactoNoticeConsent/components/Checkbox.tsx
|
|
520
470
|
import { TouchableOpacity, View, StyleSheet } from "react-native";
|
|
521
471
|
import Svg, { Path } from "react-native-svg";
|
|
@@ -1745,6 +1695,12 @@ var RedactoNoticeConsent = ({
|
|
|
1745
1695
|
noticeId,
|
|
1746
1696
|
accessToken,
|
|
1747
1697
|
refreshToken: _refreshToken,
|
|
1698
|
+
token,
|
|
1699
|
+
email,
|
|
1700
|
+
mobile,
|
|
1701
|
+
ucic,
|
|
1702
|
+
organisationUuid,
|
|
1703
|
+
workspaceUuid,
|
|
1748
1704
|
baseUrl,
|
|
1749
1705
|
ledgerBaseUrl,
|
|
1750
1706
|
settings,
|
|
@@ -1760,6 +1716,16 @@ var RedactoNoticeConsent = ({
|
|
|
1760
1716
|
}) => {
|
|
1761
1717
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
1762
1718
|
const { isMobile } = useResponsive();
|
|
1719
|
+
const sandboxParams = useMemo(
|
|
1720
|
+
() => ({
|
|
1721
|
+
token,
|
|
1722
|
+
sandboxUcic: ucic,
|
|
1723
|
+
sandboxSubject: email || mobile,
|
|
1724
|
+
organisationUuid,
|
|
1725
|
+
workspaceUuid
|
|
1726
|
+
}),
|
|
1727
|
+
[token, ucic, email, mobile, organisationUuid, workspaceUuid]
|
|
1728
|
+
);
|
|
1763
1729
|
const [content, setContent] = useState(null);
|
|
1764
1730
|
const [isLoading, setIsLoading] = useState(true);
|
|
1765
1731
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
@@ -1806,7 +1772,6 @@ var RedactoNoticeConsent = ({
|
|
|
1806
1772
|
const abortControllerRef = useRef2(null);
|
|
1807
1773
|
const hasBootstrappedLanguageRef = useRef2(false);
|
|
1808
1774
|
const fetchContent = useCallback(async () => {
|
|
1809
|
-
var _a2, _b2;
|
|
1810
1775
|
if (abortControllerRef.current) {
|
|
1811
1776
|
abortControllerRef.current.abort();
|
|
1812
1777
|
}
|
|
@@ -1814,34 +1779,21 @@ var RedactoNoticeConsent = ({
|
|
|
1814
1779
|
setIsLoading(true);
|
|
1815
1780
|
setErrorMessage(null);
|
|
1816
1781
|
try {
|
|
1782
|
+
const noticeBaseUrl = ledgerBaseUrl && !applicationId && !token ? ledgerBaseUrl : baseUrl;
|
|
1817
1783
|
const data = await fetchConsentContent({
|
|
1818
1784
|
noticeId,
|
|
1819
1785
|
accessToken,
|
|
1820
|
-
baseUrl,
|
|
1786
|
+
baseUrl: noticeBaseUrl,
|
|
1821
1787
|
language: "English",
|
|
1822
1788
|
validate_against: validateAgainst,
|
|
1823
1789
|
include_fully_consented_data: includeFullyConsentedData,
|
|
1824
1790
|
specific_uuid: applicationId,
|
|
1825
|
-
signal: abortControllerRef.current.signal
|
|
1791
|
+
signal: abortControllerRef.current.signal,
|
|
1792
|
+
...sandboxParams
|
|
1826
1793
|
});
|
|
1827
1794
|
const activeConfig2 = data.detail.active_config;
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
if (ledgerBaseUrl && !applicationId) {
|
|
1831
|
-
const ledgerStatus = await fetchNoticeConsentStatus({
|
|
1832
|
-
accessToken,
|
|
1833
|
-
ledgerBaseUrl,
|
|
1834
|
-
noticeUuid: noticeId,
|
|
1835
|
-
signal: (_a2 = abortControllerRef.current) == null ? void 0 : _a2.signal
|
|
1836
|
-
});
|
|
1837
|
-
if (ledgerStatus) {
|
|
1838
|
-
const overlay = buildLedgerConsentOverlay(ledgerStatus, activeConfig2.purposes);
|
|
1839
|
-
reconsentRequired = (_b2 = overlay == null ? void 0 : overlay.reconsent_required) != null ? _b2 : false;
|
|
1840
|
-
purposeSelections = overlay == null ? void 0 : overlay.purpose_selections;
|
|
1841
|
-
data.detail.purpose_selections = purposeSelections;
|
|
1842
|
-
data.detail.reconsent_required = reconsentRequired;
|
|
1843
|
-
}
|
|
1844
|
-
}
|
|
1795
|
+
const purposeSelections = data.detail.purpose_selections;
|
|
1796
|
+
const reconsentRequired = data.detail.reconsent_required || false;
|
|
1845
1797
|
const noticeIsMinor = data.detail.is_minor || false;
|
|
1846
1798
|
setIsMinor(noticeIsMinor);
|
|
1847
1799
|
const initialCollapsed = {};
|
|
@@ -1854,9 +1806,9 @@ var RedactoNoticeConsent = ({
|
|
|
1854
1806
|
const purposeSelected = sel ? sel.selected : false;
|
|
1855
1807
|
initialPurposeState[purpose.uuid] = purposeSelected;
|
|
1856
1808
|
purpose.data_elements.forEach((el) => {
|
|
1857
|
-
var
|
|
1809
|
+
var _a2, _b2, _c2;
|
|
1858
1810
|
const combinedId = `${purpose.uuid}-${el.uuid}`;
|
|
1859
|
-
const elementSel = (_c2 = (
|
|
1811
|
+
const elementSel = (_c2 = (_b2 = (_a2 = sel == null ? void 0 : sel.data_elements) == null ? void 0 : _a2[el.uuid]) == null ? void 0 : _b2.selected) != null ? _c2 : false;
|
|
1860
1812
|
initialDataElementState[combinedId] = elementSel;
|
|
1861
1813
|
initialDataElementSelectionsMap[combinedId] = elementSel;
|
|
1862
1814
|
});
|
|
@@ -1904,7 +1856,7 @@ var RedactoNoticeConsent = ({
|
|
|
1904
1856
|
} finally {
|
|
1905
1857
|
setIsLoading(false);
|
|
1906
1858
|
}
|
|
1907
|
-
}, [noticeId, accessToken, baseUrl, ledgerBaseUrl, validateAgainst, includeFullyConsentedData, applicationId, onAccept, onError]);
|
|
1859
|
+
}, [noticeId, accessToken, sandboxParams, token, baseUrl, ledgerBaseUrl, validateAgainst, includeFullyConsentedData, applicationId, onAccept, onError]);
|
|
1908
1860
|
useEffect2(() => {
|
|
1909
1861
|
hasBootstrappedLanguageRef.current = false;
|
|
1910
1862
|
}, [noticeId, accessToken]);
|
|
@@ -1925,8 +1877,10 @@ var RedactoNoticeConsent = ({
|
|
|
1925
1877
|
const data = await fetchTTSAudioUrls({
|
|
1926
1878
|
accessToken,
|
|
1927
1879
|
baseUrl,
|
|
1880
|
+
ledgerBaseUrl,
|
|
1928
1881
|
noticeUuid: content.detail.active_config.notice_uuid,
|
|
1929
|
-
language: selectedLanguage
|
|
1882
|
+
language: selectedLanguage,
|
|
1883
|
+
...sandboxParams
|
|
1930
1884
|
});
|
|
1931
1885
|
const urls = {
|
|
1932
1886
|
notice_text: data.detail.notice_text_audio_url,
|
|
@@ -1980,7 +1934,7 @@ var RedactoNoticeConsent = ({
|
|
|
1980
1934
|
setTtsAudioUrls({});
|
|
1981
1935
|
setIsTTSAvailable(false);
|
|
1982
1936
|
}
|
|
1983
|
-
}, [content, accessToken, baseUrl, selectedLanguage]);
|
|
1937
|
+
}, [content, accessToken, sandboxParams, baseUrl, ledgerBaseUrl, selectedLanguage]);
|
|
1984
1938
|
const clearPlaybackWatchers = useCallback(() => {
|
|
1985
1939
|
if (playbackSubscriptionRef.current) {
|
|
1986
1940
|
playbackSubscriptionRef.current.remove();
|
|
@@ -2320,7 +2274,9 @@ var RedactoNoticeConsent = ({
|
|
|
2320
2274
|
declined: false,
|
|
2321
2275
|
meta_data: applicationId ? { specific_uuid: applicationId } : void 0,
|
|
2322
2276
|
guardianVerificationReference: verificationReferenceRef.current || void 0,
|
|
2323
|
-
selfDeclaredAdult: selfDeclaredAdult || void 0
|
|
2277
|
+
selfDeclaredAdult: selfDeclaredAdult || void 0,
|
|
2278
|
+
language: selectedLanguage,
|
|
2279
|
+
...sandboxParams
|
|
2324
2280
|
});
|
|
2325
2281
|
await stopAudio();
|
|
2326
2282
|
clearApiCache();
|
|
@@ -2335,7 +2291,7 @@ var RedactoNoticeConsent = ({
|
|
|
2335
2291
|
} finally {
|
|
2336
2292
|
setIsSubmitting(false);
|
|
2337
2293
|
}
|
|
2338
|
-
}, [content, accessToken, baseUrl, ledgerBaseUrl, applicationId, selectedPurposes, selectedDataElements, stopAudio, onAccept, onError]);
|
|
2294
|
+
}, [content, accessToken, sandboxParams, baseUrl, ledgerBaseUrl, applicationId, selectedPurposes, selectedDataElements, selectedLanguage, selfDeclaredAdult, stopAudio, onAccept, onError]);
|
|
2339
2295
|
const handleDecline = useCallback(() => {
|
|
2340
2296
|
stopAudio();
|
|
2341
2297
|
stopPolling();
|
|
@@ -2950,14 +2906,16 @@ var fetchConsentContent2 = async ({
|
|
|
2950
2906
|
org_uuid,
|
|
2951
2907
|
workspace_uuid,
|
|
2952
2908
|
notice_uuid,
|
|
2909
|
+
accessToken,
|
|
2953
2910
|
baseUrl,
|
|
2954
2911
|
language = "en",
|
|
2955
2912
|
specific_uuid,
|
|
2956
2913
|
signal
|
|
2957
2914
|
}) => {
|
|
2958
2915
|
const apiBaseUrl = baseUrl || DEFAULT_CONSENT_API_BASE_URL;
|
|
2916
|
+
const noticesUrl = `${apiBaseUrl}/public/organisations/${org_uuid}/workspaces/${workspace_uuid}/notices`;
|
|
2959
2917
|
const url = new URL(
|
|
2960
|
-
`${
|
|
2918
|
+
accessToken ? `${noticesUrl}/${notice_uuid}` : `${noticesUrl}/get-notice/${notice_uuid}`
|
|
2961
2919
|
);
|
|
2962
2920
|
if (specific_uuid) {
|
|
2963
2921
|
url.searchParams.append("specific_uuid", specific_uuid);
|
|
@@ -2966,7 +2924,8 @@ var fetchConsentContent2 = async ({
|
|
|
2966
2924
|
method: "GET",
|
|
2967
2925
|
headers: {
|
|
2968
2926
|
"Content-Type": "application/json",
|
|
2969
|
-
"Accept-Language": language
|
|
2927
|
+
"Accept-Language": language,
|
|
2928
|
+
...accessToken ? { Authorization: `Bearer ${accessToken}` } : {}
|
|
2970
2929
|
},
|
|
2971
2930
|
signal
|
|
2972
2931
|
});
|
|
@@ -3000,7 +2959,8 @@ var submitConsentEvent2 = async ({
|
|
|
3000
2959
|
noticeUuid,
|
|
3001
2960
|
purposes,
|
|
3002
2961
|
declined,
|
|
3003
|
-
meta_data
|
|
2962
|
+
meta_data,
|
|
2963
|
+
language
|
|
3004
2964
|
}) => {
|
|
3005
2965
|
var _a, _b;
|
|
3006
2966
|
const apiBaseUrl = ledgerBaseUrl || baseUrl || DEFAULT_CONSENT_API_BASE_URL;
|
|
@@ -3023,7 +2983,8 @@ var submitConsentEvent2 = async ({
|
|
|
3023
2983
|
select_all_mandatory: false,
|
|
3024
2984
|
source: "MOBILE",
|
|
3025
2985
|
declined,
|
|
3026
|
-
meta_data
|
|
2986
|
+
meta_data,
|
|
2987
|
+
language: toLanguageCode(language)
|
|
3027
2988
|
};
|
|
3028
2989
|
const response = await fetch(
|
|
3029
2990
|
`${apiBaseUrl}/public/organisations/${org_uuid}/workspaces/${workspace_uuid}/submit-consent`,
|
|
@@ -3062,6 +3023,46 @@ var submitConsentEvent2 = async ({
|
|
|
3062
3023
|
}
|
|
3063
3024
|
};
|
|
3064
3025
|
|
|
3026
|
+
// src/shared/notice-consent-status.ts
|
|
3027
|
+
var fetchNoticeConsentStatusForScope = async ({
|
|
3028
|
+
accessToken,
|
|
3029
|
+
ledgerBaseUrl,
|
|
3030
|
+
organisationUuid,
|
|
3031
|
+
workspaceUuid,
|
|
3032
|
+
noticeUuid,
|
|
3033
|
+
signal
|
|
3034
|
+
}) => {
|
|
3035
|
+
if (!accessToken || !ledgerBaseUrl || !organisationUuid || !workspaceUuid || !noticeUuid) {
|
|
3036
|
+
return null;
|
|
3037
|
+
}
|
|
3038
|
+
try {
|
|
3039
|
+
const response = await fetch(
|
|
3040
|
+
`${ledgerBaseUrl}/public/organisations/${organisationUuid}/workspaces/${workspaceUuid}/notices/${noticeUuid}/check-consent`,
|
|
3041
|
+
{
|
|
3042
|
+
method: "POST",
|
|
3043
|
+
headers: {
|
|
3044
|
+
Authorization: `Bearer ${accessToken}`,
|
|
3045
|
+
"Content-Type": "application/json"
|
|
3046
|
+
},
|
|
3047
|
+
body: "{}",
|
|
3048
|
+
signal
|
|
3049
|
+
}
|
|
3050
|
+
);
|
|
3051
|
+
if (!response.ok) {
|
|
3052
|
+
return null;
|
|
3053
|
+
}
|
|
3054
|
+
const data = await response.json();
|
|
3055
|
+
const body = data && typeof data === "object" && "detail" in data && data.detail ? data.detail : data;
|
|
3056
|
+
if (!body || !Array.isArray(body.purposes)) {
|
|
3057
|
+
return null;
|
|
3058
|
+
}
|
|
3059
|
+
return body;
|
|
3060
|
+
} catch {
|
|
3061
|
+
return null;
|
|
3062
|
+
}
|
|
3063
|
+
};
|
|
3064
|
+
var isNoticeFullyConsented = (status) => status.consented && status.all_mandatory_active;
|
|
3065
|
+
|
|
3065
3066
|
// src/RedactoNoticeConsentInline/styles.ts
|
|
3066
3067
|
import { StyleSheet as StyleSheet5, Platform as Platform2 } from "react-native";
|
|
3067
3068
|
var styles3 = StyleSheet5.create({
|
|
@@ -3405,11 +3406,13 @@ var RedactoConsentInlineComponent = ({
|
|
|
3405
3406
|
const fetchNotice = useCallback2(async (signal) => {
|
|
3406
3407
|
setIsLoading(true);
|
|
3407
3408
|
setFetchError(null);
|
|
3409
|
+
setHasAlreadyConsented(false);
|
|
3408
3410
|
try {
|
|
3409
3411
|
const consentContentData = await fetchConsentContent2({
|
|
3410
3412
|
org_uuid,
|
|
3411
3413
|
workspace_uuid,
|
|
3412
3414
|
notice_uuid,
|
|
3415
|
+
accessToken,
|
|
3413
3416
|
baseUrl,
|
|
3414
3417
|
language,
|
|
3415
3418
|
specific_uuid: applicationId,
|
|
@@ -3459,7 +3462,7 @@ var RedactoConsentInlineComponent = ({
|
|
|
3459
3462
|
setIsLoading(false);
|
|
3460
3463
|
}
|
|
3461
3464
|
}
|
|
3462
|
-
}, [org_uuid, workspace_uuid, notice_uuid, baseUrl, language, applicationId, onError]);
|
|
3465
|
+
}, [org_uuid, workspace_uuid, notice_uuid, accessToken, baseUrl, language, applicationId, onError]);
|
|
3463
3466
|
useEffect3(() => {
|
|
3464
3467
|
const controller = new AbortController();
|
|
3465
3468
|
void fetchNotice(controller.signal);
|
|
@@ -3571,7 +3574,8 @@ var RedactoConsentInlineComponent = ({
|
|
|
3571
3574
|
};
|
|
3572
3575
|
}),
|
|
3573
3576
|
declined: false,
|
|
3574
|
-
meta_data: applicationId ? { specific_uuid: applicationId } : void 0
|
|
3577
|
+
meta_data: applicationId ? { specific_uuid: applicationId } : void 0,
|
|
3578
|
+
language: selectedLanguage
|
|
3575
3579
|
});
|
|
3576
3580
|
onAccept == null ? void 0 : onAccept();
|
|
3577
3581
|
hasSubmittedRef.current = false;
|
|
@@ -3594,6 +3598,7 @@ var RedactoConsentInlineComponent = ({
|
|
|
3594
3598
|
selectedDataElements,
|
|
3595
3599
|
selectedPurposes,
|
|
3596
3600
|
applicationId,
|
|
3601
|
+
selectedLanguage,
|
|
3597
3602
|
onAccept
|
|
3598
3603
|
]
|
|
3599
3604
|
);
|