@redacto.io/consent-sdk-react-native 5.0.0-beta.5 → 5.0.0-beta.7

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.
@@ -9863,6 +9863,36 @@ function useSafeInsets() {
9863
9863
  // src/RedactoPrivacyCenter/context/BaseUrlContext.tsx
9864
9864
  var import_react2 = require("react");
9865
9865
 
9866
+ // src/shared/sandbox.ts
9867
+ var SANDBOX_TOKEN_HEADER = "X-Consent-Token";
9868
+
9869
+ // src/RedactoPrivacyCenter/lib/sandbox.ts
9870
+ var sandboxConfig = null;
9871
+ var setSandboxConfig = (config) => {
9872
+ sandboxConfig = config;
9873
+ };
9874
+ var getSandboxConfig = () => sandboxConfig;
9875
+ var isSandboxMode = () => sandboxConfig !== null;
9876
+ var sandboxAuthHeaders = () => {
9877
+ if (!sandboxConfig) {
9878
+ return null;
9879
+ }
9880
+ return {
9881
+ [SANDBOX_TOKEN_HEADER]: sandboxConfig.token
9882
+ };
9883
+ };
9884
+ var sandboxBodyIdentity = () => {
9885
+ if (!sandboxConfig) {
9886
+ return null;
9887
+ }
9888
+ if (sandboxConfig.ucic) {
9889
+ return { org_user_id: sandboxConfig.ucic };
9890
+ }
9891
+ return sandboxConfig.subject.includes("@") ? { primary_email: sandboxConfig.subject } : { primary_mobile: sandboxConfig.subject };
9892
+ };
9893
+ var sandboxQueryIdentity = () => sandboxBodyIdentity();
9894
+ var sandboxContact = () => sandboxConfig ? sandboxConfig.ucic || sandboxConfig.subject : null;
9895
+
9866
9896
  // src/RedactoPrivacyCenter/api/fetcher.ts
9867
9897
  async function apiFetch(url, options = {}) {
9868
9898
  const { getAuthToken, headers = {}, ...fetchOptions } = options;
@@ -9888,11 +9918,18 @@ async function apiFetch(url, options = {}) {
9888
9918
  }
9889
9919
  }
9890
9920
  if (getAuthToken) {
9891
- const token = await getAuthToken();
9892
- if (token) {
9893
- const trimmedToken = token.trim();
9894
- requestHeaders.set("X-Auth-Token", trimmedToken);
9895
- requestHeaders.set("x-auth-token", trimmedToken);
9921
+ const sandboxHeaders = sandboxAuthHeaders();
9922
+ if (sandboxHeaders) {
9923
+ Object.entries(sandboxHeaders).forEach(([key, value]) => {
9924
+ requestHeaders.set(key, value);
9925
+ });
9926
+ } else {
9927
+ const token = await getAuthToken();
9928
+ if (token) {
9929
+ const trimmedToken = token.trim();
9930
+ requestHeaders.set("X-Auth-Token", trimmedToken);
9931
+ requestHeaders.set("x-auth-token", trimmedToken);
9932
+ }
9896
9933
  }
9897
9934
  }
9898
9935
  const fetchOptionsFinal = {
@@ -9983,14 +10020,29 @@ function arrayBufferToBase64(buffer) {
9983
10020
  return result;
9984
10021
  }
9985
10022
  function createConsentClient(baseUrl, ledgerBaseUrl) {
9986
- const useLedger = Boolean(ledgerBaseUrl);
10023
+ const ledgerConfigured = Boolean(ledgerBaseUrl);
10024
+ const useLedger = () => ledgerConfigured && !isSandboxMode();
9987
10025
  const ledgerBase = (ledgerBaseUrl != null ? ledgerBaseUrl : "").replace(/\/$/, "");
9988
10026
  function ledgerUrl(baseRequest, path) {
9989
- if (!useLedger) {
10027
+ if (!useLedger()) {
9990
10028
  throw new Error("ledgerUrl called without a configured ledgerBaseUrl");
9991
10029
  }
9992
10030
  return `${ledgerBase}/public/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}${path}`;
9993
10031
  }
10032
+ function appendSandboxIdentity(queryParams) {
10033
+ const identity = sandboxQueryIdentity();
10034
+ if (identity) {
10035
+ Object.entries(identity).forEach(([key, value]) => {
10036
+ queryParams.append(key, value);
10037
+ });
10038
+ }
10039
+ }
10040
+ function sandboxIdentitySuffix() {
10041
+ const queryParams = new URLSearchParams();
10042
+ appendSandboxIdentity(queryParams);
10043
+ const queryString = queryParams.toString();
10044
+ return queryString ? `?${queryString}` : "";
10045
+ }
9994
10046
  async function privacyCenterApiFetch(url, options) {
9995
10047
  const { authToken, getAuthToken, headers = {}, ...fetchOptions } = options;
9996
10048
  const requestHeaders = new Headers();
@@ -10014,11 +10066,18 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10014
10066
  );
10015
10067
  }
10016
10068
  }
10017
- const token = authToken || (getAuthToken ? await getAuthToken() : null);
10018
- if (token) {
10019
- const trimmedToken = token.trim();
10020
- const bearerToken = trimmedToken.startsWith("Bearer ") ? trimmedToken : `Bearer ${trimmedToken}`;
10021
- requestHeaders.set("Authorization", bearerToken);
10069
+ const sandboxHeaders = sandboxAuthHeaders();
10070
+ if (sandboxHeaders) {
10071
+ Object.entries(sandboxHeaders).forEach(([key, value]) => {
10072
+ requestHeaders.set(key, value);
10073
+ });
10074
+ } else {
10075
+ const token = authToken || (getAuthToken ? await getAuthToken() : null);
10076
+ if (token) {
10077
+ const trimmedToken = token.trim();
10078
+ const bearerToken = trimmedToken.startsWith("Bearer ") ? trimmedToken : `Bearer ${trimmedToken}`;
10079
+ requestHeaders.set("Authorization", bearerToken);
10080
+ }
10022
10081
  }
10023
10082
  const fetchOptionsFinal = {
10024
10083
  ...fetchOptions,
@@ -10099,18 +10158,20 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10099
10158
  async createCaseRequest(baseRequest, payload, authToken, options) {
10100
10159
  const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/case`;
10101
10160
  const { useSessionAuth = false, getAuthToken, ...fetchOptions } = options || {};
10161
+ const contact = sandboxContact();
10162
+ const requestPayload = contact && payload && typeof payload === "object" ? { ...payload, contact } : payload;
10102
10163
  if (useSessionAuth) {
10103
10164
  return apiFetch(url, {
10104
10165
  ...fetchOptions,
10105
10166
  method: "POST",
10106
- body: JSON.stringify(payload),
10167
+ body: JSON.stringify(requestPayload),
10107
10168
  getAuthToken
10108
10169
  });
10109
10170
  }
10110
10171
  return privacyCenterApiFetch(url, {
10111
10172
  ...fetchOptions,
10112
10173
  method: "POST",
10113
- body: JSON.stringify(payload),
10174
+ body: JSON.stringify(requestPayload),
10114
10175
  authToken: authToken || baseRequest.authToken
10115
10176
  });
10116
10177
  },
@@ -10191,9 +10252,10 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10191
10252
  if (params.status) queryParams.append("status", params.status);
10192
10253
  if (params.product_uuid) queryParams.append("product_uuid", params.product_uuid);
10193
10254
  if (params.language) queryParams.append("language", params.language);
10255
+ appendSandboxIdentity(queryParams);
10194
10256
  const queryString = queryParams.toString();
10195
10257
  const consentsSuffix = `/user-consents${queryString ? `?${queryString}` : ""}`;
10196
- const url = useLedger ? ledgerUrl(baseRequest, consentsSuffix) : `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center${consentsSuffix}`;
10258
+ const url = useLedger() ? ledgerUrl(baseRequest, consentsSuffix) : `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center${consentsSuffix}`;
10197
10259
  return privacyCenterApiFetch(url, {
10198
10260
  ...options,
10199
10261
  method: "GET",
@@ -10212,9 +10274,10 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10212
10274
  if (params.search) queryParams.append("search", params.search);
10213
10275
  if (params.language) queryParams.append("language", params.language);
10214
10276
  if (params.nominator_uuid) queryParams.append("nominator_uuid", params.nominator_uuid);
10277
+ appendSandboxIdentity(queryParams);
10215
10278
  const queryString = queryParams.toString();
10216
10279
  const purposesSuffix = `/user-consents/${productUuid}/purposes${queryString ? `?${queryString}` : ""}`;
10217
- const url = useLedger ? ledgerUrl(baseRequest, purposesSuffix) : `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center${purposesSuffix}`;
10280
+ const url = useLedger() ? ledgerUrl(baseRequest, purposesSuffix) : `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center${purposesSuffix}`;
10218
10281
  return privacyCenterApiFetch(url, {
10219
10282
  ...options,
10220
10283
  method: "GET",
@@ -10236,9 +10299,13 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10236
10299
  * used with its `{ purpose_uuid, contact, ... }` payload.
10237
10300
  */
10238
10301
  async manageConsent(baseRequest, purposeId, contact, status, authToken, options, nominatorContact, dataElementUuids, noticeUuid, dataElements, language) {
10239
- if (!useLedger) {
10302
+ if (!useLedger()) {
10240
10303
  const url2 = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/manage-consent?status=${status}`;
10241
- const body2 = { purpose_uuid: purposeId, contact };
10304
+ const sandboxSingleContact = sandboxContact();
10305
+ const body2 = {
10306
+ purpose_uuid: purposeId,
10307
+ contact: sandboxSingleContact != null ? sandboxSingleContact : contact
10308
+ };
10242
10309
  if (nominatorContact) {
10243
10310
  body2.nominator_contact = nominatorContact;
10244
10311
  }
@@ -10301,6 +10368,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10301
10368
  if (offset !== void 0) queryParams.append("offset", offset.toString());
10302
10369
  if (limit !== void 0) queryParams.append("limit", limit.toString());
10303
10370
  if (language) queryParams.append("language", language);
10371
+ appendSandboxIdentity(queryParams);
10304
10372
  const queryString = queryParams.toString();
10305
10373
  const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/activities${queryString ? `?${queryString}` : ""}`;
10306
10374
  return privacyCenterApiFetch(url, {
@@ -10321,9 +10389,10 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10321
10389
  if (params.created_before) queryParams.append("created_before", params.created_before);
10322
10390
  if (params.notice_uuid) queryParams.append("notice_uuid", params.notice_uuid);
10323
10391
  if (params.language) queryParams.append("language", params.language);
10392
+ appendSandboxIdentity(queryParams);
10324
10393
  const queryString = queryParams.toString();
10325
10394
  const receiptsSuffix = `/receipts${queryString ? `?${queryString}` : ""}`;
10326
- const url = useLedger ? ledgerUrl(baseRequest, receiptsSuffix) : `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center${receiptsSuffix}`;
10395
+ const url = useLedger() ? ledgerUrl(baseRequest, receiptsSuffix) : `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center${receiptsSuffix}`;
10327
10396
  return privacyCenterApiFetch(url, {
10328
10397
  ...options,
10329
10398
  method: "GET",
@@ -10337,11 +10406,16 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10337
10406
  * the RN UI writes to a temp file to open/share. 404 => not found.
10338
10407
  */
10339
10408
  async getReceiptPdf(baseRequest, receiptUuid, authToken) {
10340
- const url = useLedger ? ledgerUrl(baseRequest, `/receipts/${receiptUuid}/download`) : `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/receipts/${receiptUuid}/pdf`;
10409
+ const url = useLedger() ? ledgerUrl(baseRequest, `/receipts/${receiptUuid}/download`) : `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/receipts/${receiptUuid}/pdf`;
10341
10410
  const token = authToken || baseRequest.authToken;
10342
10411
  const requestHeaders = new Headers();
10343
10412
  requestHeaders.set("Accept", "application/pdf");
10344
- if (token) {
10413
+ const sandboxHeaders = sandboxAuthHeaders();
10414
+ if (sandboxHeaders) {
10415
+ Object.entries(sandboxHeaders).forEach(([key, value]) => {
10416
+ requestHeaders.set(key, value);
10417
+ });
10418
+ } else if (token) {
10345
10419
  const trimmedToken = token.trim();
10346
10420
  const bearerToken = trimmedToken.startsWith("Bearer ") ? trimmedToken : `Bearer ${trimmedToken}`;
10347
10421
  requestHeaders.set("Authorization", bearerToken);
@@ -10367,6 +10441,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10367
10441
  if (offset !== void 0) queryParams.append("offset", offset.toString());
10368
10442
  if (limit !== void 0) queryParams.append("limit", limit.toString());
10369
10443
  if (language) queryParams.append("language", language);
10444
+ appendSandboxIdentity(queryParams);
10370
10445
  const queryString = queryParams.toString();
10371
10446
  const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/cases?${queryString}`;
10372
10447
  return privacyCenterApiFetch(url, {
@@ -10378,7 +10453,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10378
10453
  * Get case messages (privacy center)
10379
10454
  */
10380
10455
  async getCaseMessages(baseRequest, caseUuid, authToken, options) {
10381
- const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/cases/${caseUuid}/messages`;
10456
+ const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/cases/${caseUuid}/messages${sandboxIdentitySuffix()}`;
10382
10457
  return privacyCenterApiFetch(url, {
10383
10458
  ...options,
10384
10459
  authToken: authToken || baseRequest.authToken
@@ -10388,7 +10463,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10388
10463
  * Send a message in a case (privacy center)
10389
10464
  */
10390
10465
  async sendCaseMessage(baseRequest, caseUuid, body, documentUuids, authToken, options) {
10391
- const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/cases/${caseUuid}/messages`;
10466
+ const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/cases/${caseUuid}/messages${sandboxIdentitySuffix()}`;
10392
10467
  return privacyCenterApiFetch(url, {
10393
10468
  ...options,
10394
10469
  method: "POST",
@@ -10400,7 +10475,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10400
10475
  * Upload a document for a case (privacy center)
10401
10476
  */
10402
10477
  async uploadCaseDocument(baseRequest, caseUuid, formData, authToken, options) {
10403
- const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/cases/${caseUuid}/upload-document`;
10478
+ const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/cases/${caseUuid}/upload-document${sandboxIdentitySuffix()}`;
10404
10479
  return privacyCenterApiFetch(url, {
10405
10480
  ...options,
10406
10481
  method: "POST",
@@ -10433,6 +10508,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10433
10508
  if ((params == null ? void 0 : params.limit) !== void 0) queryParams.append("limit", params.limit.toString());
10434
10509
  if (params == null ? void 0 : params.include_summary) queryParams.append("include_summary", "true");
10435
10510
  if (params == null ? void 0 : params.language) queryParams.append("language", params.language);
10511
+ appendSandboxIdentity(queryParams);
10436
10512
  const queryString = queryParams.toString();
10437
10513
  const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/notifications/${queryString ? `?${queryString}` : ""}`;
10438
10514
  return privacyCenterApiFetch(url, {
@@ -10444,7 +10520,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10444
10520
  * Get notification summary (aggregated counts only)
10445
10521
  */
10446
10522
  async getNotificationSummary(baseRequest, authToken) {
10447
- const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/notifications/summary`;
10523
+ const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/notifications/summary${sandboxIdentitySuffix()}`;
10448
10524
  return privacyCenterApiFetch(url, {
10449
10525
  method: "GET",
10450
10526
  authToken: authToken || baseRequest.authToken
@@ -10454,7 +10530,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10454
10530
  * Get unread notification count (lightweight, for the header badge)
10455
10531
  */
10456
10532
  async getUnreadCount(baseRequest, authToken) {
10457
- const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/notifications/unread-count`;
10533
+ const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/notifications/unread-count${sandboxIdentitySuffix()}`;
10458
10534
  return privacyCenterApiFetch(url, {
10459
10535
  method: "GET",
10460
10536
  authToken: authToken || baseRequest.authToken
@@ -10464,7 +10540,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10464
10540
  * Mark a single notification as read
10465
10541
  */
10466
10542
  async markNotificationRead(baseRequest, notificationUuid, authToken) {
10467
- const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/notifications/${notificationUuid}/read`;
10543
+ const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/notifications/${notificationUuid}/read${sandboxIdentitySuffix()}`;
10468
10544
  return privacyCenterApiFetch(url, {
10469
10545
  method: "PATCH",
10470
10546
  authToken: authToken || baseRequest.authToken
@@ -10474,7 +10550,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10474
10550
  * Mark all notifications as read
10475
10551
  */
10476
10552
  async markAllNotificationsRead(baseRequest, authToken) {
10477
- const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/notifications/mark-all-read`;
10553
+ const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/notifications/mark-all-read${sandboxIdentitySuffix()}`;
10478
10554
  return privacyCenterApiFetch(url, {
10479
10555
  method: "POST",
10480
10556
  authToken: authToken || baseRequest.authToken
@@ -10484,7 +10560,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10484
10560
  * Acknowledge a notification (sets is_read and is_acknowledged to true)
10485
10561
  */
10486
10562
  async acknowledgeNotification(baseRequest, notificationUuid, authToken) {
10487
- const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/notifications/${notificationUuid}/acknowledge`;
10563
+ const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/notifications/${notificationUuid}/acknowledge${sandboxIdentitySuffix()}`;
10488
10564
  return privacyCenterApiFetch(url, {
10489
10565
  method: "POST",
10490
10566
  authToken: authToken || baseRequest.authToken
@@ -11677,6 +11753,10 @@ var compareEmails = (email1, email2) => {
11677
11753
  return decodeURIComponent(email1.trim()).toLowerCase() === email2.trim().toLowerCase();
11678
11754
  };
11679
11755
  var ensureValidToken = async (organizationId, workspaceId, _slug, authContext, consentClient) => {
11756
+ const sandbox = getSandboxConfig();
11757
+ if (sandbox) {
11758
+ return sandbox.token;
11759
+ }
11680
11760
  const accessToken = (authContext == null ? void 0 : authContext.accessToken) || getStoredValue("access_token");
11681
11761
  if (accessToken && typeof accessToken === "string" && accessToken.trim() !== "" && !isJwtExpired(accessToken, TOKEN_EXPIRY_BUFFER_SECONDS)) {
11682
11762
  return accessToken;
@@ -11814,15 +11894,73 @@ function syncJwtDataToStore(token) {
11814
11894
  if (authData.workspaceId) setStoredValue("pc_workspace_id", authData.workspaceId);
11815
11895
  return authData;
11816
11896
  }
11817
- function AuthProvider({ children, accessToken: initialAccessToken, refreshToken: initialRefreshToken, onError }) {
11818
- const initialAuth = extractJwtAuthData(initialAccessToken);
11897
+ function configureSandbox(props) {
11898
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
11899
+ const token = (_a3 = props.token) == null ? void 0 : _a3.trim();
11900
+ if (!token) {
11901
+ setSandboxConfig(null);
11902
+ return null;
11903
+ }
11904
+ const organisationUuid = (_c = (_b = props.organisationUuid) == null ? void 0 : _b.trim()) != null ? _c : "";
11905
+ const workspaceUuid = (_e = (_d = props.workspaceUuid) == null ? void 0 : _d.trim()) != null ? _e : "";
11906
+ const ucic = (_g = (_f = props.sandboxUcic) == null ? void 0 : _f.trim()) != null ? _g : "";
11907
+ const subject = (_i = (_h = props.sandboxSubject) == null ? void 0 : _h.trim()) != null ? _i : "";
11908
+ const slug = (_k = (_j = props.slug) == null ? void 0 : _j.trim()) != null ? _k : "";
11909
+ if (!organisationUuid || !workspaceUuid) {
11910
+ throw new Error("Sandbox mode requires organisationUuid and workspaceUuid props");
11911
+ }
11912
+ if (!ucic && !subject) {
11913
+ throw new Error("Sandbox mode requires a UCIC, email, or mobile");
11914
+ }
11915
+ setSandboxConfig({
11916
+ token,
11917
+ ucic: ucic || void 0,
11918
+ subject,
11919
+ organisationUuid,
11920
+ workspaceUuid,
11921
+ slug
11922
+ });
11923
+ const contact = ucic || subject;
11924
+ setStoredValue("access_token", token);
11925
+ if (organisationUuid) setStoredValue("pc_org_id", organisationUuid);
11926
+ if (workspaceUuid) setStoredValue("pc_workspace_id", workspaceUuid);
11927
+ if (contact) setStoredValue("email", contact);
11928
+ return {
11929
+ email: contact || null,
11930
+ organizationId: organisationUuid || null,
11931
+ workspaceId: workspaceUuid || null,
11932
+ organizationName: null
11933
+ };
11934
+ }
11935
+ function AuthProvider(props) {
11936
+ const {
11937
+ children,
11938
+ accessToken: initialAccessToken,
11939
+ refreshToken: initialRefreshToken,
11940
+ token: sandboxToken,
11941
+ sandboxUcic,
11942
+ sandboxSubject,
11943
+ organisationUuid,
11944
+ workspaceUuid,
11945
+ slug,
11946
+ onError
11947
+ } = props;
11948
+ const [sandboxAuth] = (0, import_react3.useState)(() => configureSandbox(props));
11949
+ const sandboxActive = sandboxAuth !== null;
11950
+ const initialAuth = sandboxAuth != null ? sandboxAuth : extractJwtAuthData(initialAccessToken);
11819
11951
  const [accessToken, setAccessToken] = (0, import_react3.useState)(() => {
11952
+ if (sandboxActive) {
11953
+ return sandboxToken != null ? sandboxToken : "";
11954
+ }
11820
11955
  if (initialAccessToken && initialAccessToken.trim() !== "") {
11821
11956
  syncJwtDataToStore(initialAccessToken);
11822
11957
  }
11823
11958
  return initialAccessToken;
11824
11959
  });
11825
11960
  const [refreshToken, setRefreshToken] = (0, import_react3.useState)(() => {
11961
+ if (sandboxActive) {
11962
+ return "";
11963
+ }
11826
11964
  if (initialRefreshToken && initialRefreshToken.trim() !== "") {
11827
11965
  setStoredValue("refresh_token", initialRefreshToken);
11828
11966
  }
@@ -11833,6 +11971,20 @@ function AuthProvider({ children, accessToken: initialAccessToken, refreshToken:
11833
11971
  const [workspaceId, setWorkspaceId] = (0, import_react3.useState)(initialAuth.workspaceId);
11834
11972
  const [organizationName, setOrganizationName] = (0, import_react3.useState)(initialAuth.organizationName);
11835
11973
  (0, import_react3.useEffect)(() => {
11974
+ if (!sandboxActive) {
11975
+ return;
11976
+ }
11977
+ const seeded = configureSandbox(props);
11978
+ if (seeded) {
11979
+ setEmail(seeded.email);
11980
+ setOrganizationId(seeded.organizationId);
11981
+ setWorkspaceId(seeded.workspaceId);
11982
+ setOrganizationName(seeded.organizationName);
11983
+ }
11984
+ return () => setSandboxConfig(null);
11985
+ }, [sandboxActive, sandboxToken, sandboxUcic, sandboxSubject, organisationUuid, workspaceUuid, slug]);
11986
+ (0, import_react3.useEffect)(() => {
11987
+ if (sandboxActive) return;
11836
11988
  if (accessToken) {
11837
11989
  const authData = syncJwtDataToStore(accessToken);
11838
11990
  setEmail(authData.email);
@@ -11840,11 +11992,13 @@ function AuthProvider({ children, accessToken: initialAccessToken, refreshToken:
11840
11992
  setWorkspaceId(authData.workspaceId);
11841
11993
  setOrganizationName(authData.organizationName);
11842
11994
  }
11843
- }, [accessToken]);
11995
+ }, [accessToken, sandboxActive]);
11844
11996
  (0, import_react3.useEffect)(() => {
11997
+ if (sandboxActive) return;
11845
11998
  if (refreshToken) setStoredValue("refresh_token", refreshToken);
11846
- }, [refreshToken]);
11999
+ }, [refreshToken, sandboxActive]);
11847
12000
  (0, import_react3.useEffect)(() => {
12001
+ if (sandboxActive) return;
11848
12002
  setAccessToken(initialAccessToken);
11849
12003
  if (initialAccessToken && initialAccessToken.trim() !== "") {
11850
12004
  const authData = syncJwtDataToStore(initialAccessToken);
@@ -11853,10 +12007,11 @@ function AuthProvider({ children, accessToken: initialAccessToken, refreshToken:
11853
12007
  setWorkspaceId(authData.workspaceId);
11854
12008
  setOrganizationName(authData.organizationName);
11855
12009
  }
11856
- }, [initialAccessToken]);
12010
+ }, [initialAccessToken, sandboxActive]);
11857
12011
  (0, import_react3.useEffect)(() => {
12012
+ if (sandboxActive) return;
11858
12013
  setRefreshToken(initialRefreshToken);
11859
- }, [initialRefreshToken]);
12014
+ }, [initialRefreshToken, sandboxActive]);
11860
12015
  const updateTokens = (0, import_react3.useCallback)((newAccessToken, newRefreshToken) => {
11861
12016
  setAccessToken(newAccessToken);
11862
12017
  if (newRefreshToken) setRefreshToken(newRefreshToken);
@@ -14128,7 +14283,7 @@ var import_react_i18next11 = require("react-i18next");
14128
14283
 
14129
14284
  // src/RedactoPrivacyCenter/lib/consentManagerUtils.ts
14130
14285
  function purposeItemToUserConsent(purpose, group) {
14131
- var _a3, _b, _c, _d;
14286
+ var _a3, _b, _c, _d, _e;
14132
14287
  return {
14133
14288
  purpose_uuid: purpose.purpose_uuid,
14134
14289
  purpose: purpose.name,
@@ -14142,6 +14297,7 @@ function purposeItemToUserConsent(purpose, group) {
14142
14297
  product_name: group.product_name,
14143
14298
  product_description: group.product_description,
14144
14299
  nominator_info: (_d = group.nominator) != null ? _d : void 0,
14300
+ revoke_warning_message: (_e = purpose.revoke_warning_message) != null ? _e : null,
14145
14301
  notice_uuid: purpose.notice_uuid
14146
14302
  };
14147
14303
  }
@@ -14336,6 +14492,7 @@ var useTimePeriodOptions = () => {
14336
14492
  var MAX_DISPLAYED_PURPOSE_NAMES_IN_ERASURE_MODAL = 3;
14337
14493
  var SEARCH_DEBOUNCE_DELAY = 500;
14338
14494
  var FORM_PICKER_GROUP_LIMIT = 100;
14495
+ var LEGACY_PRODUCT_GROUP_UUID = "__legacy_flat_purposes__";
14339
14496
  var POLL_INTERVAL = 3e4;
14340
14497
  var NOTIFICATION_PAGE_SIZE = 10;
14341
14498
  var TAB_TO_CATEGORY = {
@@ -14438,7 +14595,7 @@ var ModifyConsentModal = ({
14438
14595
  action: "revoke",
14439
14596
  buttonLabel: t("revokeConsent"),
14440
14597
  buttonColor: colors.error,
14441
- warningMessage: t("revokeConsentWarning"),
14598
+ warningMessage: selectedRecord.revoke_warning_message || t("revokeConsentWarning"),
14442
14599
  description: nominatorLabel ? t("aboutToModifyConsentOnBehalf", { nominator: nominatorLabel }) : t("aboutToModifyConsent")
14443
14600
  };
14444
14601
  }
@@ -16327,19 +16484,32 @@ var consentGroupToFormProductGroup = (group) => {
16327
16484
  };
16328
16485
  };
16329
16486
  var purposeItemToFormPurpose = (purpose) => {
16330
- var _a3, _b;
16487
+ var _a3, _b, _c, _d, _e, _f;
16331
16488
  return {
16332
- uuid: purpose.purpose_uuid,
16333
- purpose_uuid: purpose.purpose_uuid,
16489
+ // The ledger keys purposes as `purpose_uuid`; the legacy Python
16490
+ // user-consents payload keys some of them as `uuid`. Accept either so the
16491
+ // picker and the submitted `purpose_uuid` resolve on both backends.
16492
+ uuid: (_b = (_a3 = purpose.purpose_uuid) != null ? _a3 : purpose.uuid) != null ? _b : "",
16493
+ purpose_uuid: (_d = (_c = purpose.purpose_uuid) != null ? _c : purpose.uuid) != null ? _d : "",
16334
16494
  name: purpose.name,
16335
- description: (_a3 = purpose.description) != null ? _a3 : "",
16495
+ description: (_e = purpose.description) != null ? _e : "",
16336
16496
  industries: "",
16337
16497
  selected: false,
16338
16498
  given_consent: false,
16339
16499
  status: purpose.status,
16340
16500
  validity: null,
16341
16501
  enabled: true,
16342
- data_elements: ((_b = purpose.data_elements) != null ? _b : []).map(consentDataElementToFormDataElement)
16502
+ data_elements: ((_f = purpose.data_elements) != null ? _f : []).map(consentDataElementToFormDataElement)
16503
+ };
16504
+ };
16505
+ var legacyFlatGroup = (form, label) => {
16506
+ var _a3;
16507
+ return {
16508
+ product_uuid: LEGACY_PRODUCT_GROUP_UUID,
16509
+ product_name: label,
16510
+ product_description: null,
16511
+ nominator: null,
16512
+ purposes: ((_a3 = form.purposes) != null ? _a3 : []).map((wrapper) => wrapper == null ? void 0 : wrapper.purpose).filter((purpose) => Boolean(purpose))
16343
16513
  };
16344
16514
  };
16345
16515
  var consentDataElementToFormDataElement = (element) => ({
@@ -16385,7 +16555,7 @@ var isProductScopedRequestType = (rt) => PRODUCT_SCOPED_REQUEST_TYPES.has(rt);
16385
16555
  function Form({ onCreateRequest }) {
16386
16556
  const { t } = (0, import_react_i18next16.useTranslation)();
16387
16557
  const { accessToken, refreshToken, email, organizationId, workspaceId, updateTokens, onError } = useAuth();
16388
- const { consentClient, baseUrl, ledgerBaseUrl } = useBaseUrl();
16558
+ const { consentClient, baseUrl } = useBaseUrl();
16389
16559
  const { colors } = useTheme();
16390
16560
  const requestTypeLabels = useRequestTypeLabels();
16391
16561
  const timePeriodOptions = useTimePeriodOptions();
@@ -16422,10 +16592,10 @@ function Form({ onCreateRequest }) {
16422
16592
  });
16423
16593
  const [uploadedDocs, setUploadedDocs] = (0, import_react29.useState)([]);
16424
16594
  const [isUploading, setIsUploading] = (0, import_react29.useState)(false);
16425
- const withLedgerPickerGroups = (0, import_react29.useCallback)(
16595
+ const withUserConsentPickerGroups = (0, import_react29.useCallback)(
16426
16596
  async (form, language) => {
16427
16597
  var _a3, _b;
16428
- if (!ledgerBaseUrl || !organizationId || !workspaceId) {
16598
+ if (!organizationId || !workspaceId) {
16429
16599
  return form;
16430
16600
  }
16431
16601
  const consents = await fetchUserConsents({
@@ -16440,16 +16610,18 @@ function Form({ onCreateRequest }) {
16440
16610
  authContext,
16441
16611
  consentClient
16442
16612
  });
16443
- if (!consents) {
16613
+ const direct = (_a3 = consents == null ? void 0 : consents.direct) != null ? _a3 : [];
16614
+ const nominated = (_b = consents == null ? void 0 : consents.nominated) != null ? _b : [];
16615
+ if (direct.length === 0 && nominated.length === 0) {
16444
16616
  return form;
16445
16617
  }
16446
16618
  return {
16447
16619
  ...form,
16448
- direct_groups: ((_a3 = consents.direct) != null ? _a3 : []).map(consentGroupToFormProductGroup),
16449
- nominated_groups: ((_b = consents.nominated) != null ? _b : []).map(consentGroupToFormProductGroup)
16620
+ direct_groups: direct.map(consentGroupToFormProductGroup),
16621
+ nominated_groups: nominated.map(consentGroupToFormProductGroup)
16450
16622
  };
16451
16623
  },
16452
- [ledgerBaseUrl, organizationId, workspaceId, authContext, consentClient]
16624
+ [organizationId, workspaceId, authContext, consentClient]
16453
16625
  );
16454
16626
  (0, import_react29.useEffect)(() => {
16455
16627
  if (!organizationId || !workspaceId || !contact) return;
@@ -16457,7 +16629,7 @@ function Form({ onCreateRequest }) {
16457
16629
  setIsLoading(true);
16458
16630
  getFormData(organizationId, workspaceId, contact, false, false, authContext, consentClient, langParam).then(async (data) => {
16459
16631
  if (!data) return;
16460
- const withGroups = await withLedgerPickerGroups(data, langParam);
16632
+ const withGroups = await withUserConsentPickerGroups(data, langParam);
16461
16633
  if (!isCancelled) setFormDataResponse(withGroups);
16462
16634
  }).catch((error) => {
16463
16635
  console.warn("Error fetching form data:", error);
@@ -16474,16 +16646,24 @@ function Form({ onCreateRequest }) {
16474
16646
  authContext,
16475
16647
  consentClient,
16476
16648
  langParam,
16477
- withLedgerPickerGroups
16649
+ withUserConsentPickerGroups
16478
16650
  ]);
16479
16651
  const allGroups = (0, import_react29.useMemo)(() => {
16480
16652
  var _a3, _b;
16481
16653
  if (!formDataResponse) return [];
16482
- return [
16654
+ const groups = [
16483
16655
  ...(_a3 = formDataResponse.direct_groups) != null ? _a3 : [],
16484
16656
  ...(_b = formDataResponse.nominated_groups) != null ? _b : []
16485
16657
  ];
16486
- }, [formDataResponse]);
16658
+ if (groups.length > 0) {
16659
+ return groups;
16660
+ }
16661
+ const flatGroup = legacyFlatGroup(formDataResponse, t("yourData"));
16662
+ if (buildGroupPurposes(flatGroup).length === 0) {
16663
+ return [];
16664
+ }
16665
+ return [flatGroup];
16666
+ }, [formDataResponse, t]);
16487
16667
  const skipProductStep = allGroups.length === 1;
16488
16668
  const selectedGroup = (0, import_react29.useMemo)(() => {
16489
16669
  var _a3, _b;
@@ -16745,7 +16925,8 @@ function Form({ onCreateRequest }) {
16745
16925
  setIsSubmitting(true);
16746
16926
  try {
16747
16927
  const isProductScoped = isProductScopedRequestType(requestType);
16748
- const anchorGroup = isProductScoped ? selectedGroup : null;
16928
+ const isLegacyFlatSelection = (selectedGroup == null ? void 0 : selectedGroup.product_uuid) === LEGACY_PRODUCT_GROUP_UUID;
16929
+ const anchorGroup = isProductScoped && !isLegacyFlatSelection ? selectedGroup : null;
16749
16930
  const updatePurposes = Array.from(selectedPurposes).map((uuid) => ({
16750
16931
  purpose_uuid: uuid,
16751
16932
  data_element_uuids: Array.from(selectedDataElements.get(uuid) || [])
@@ -20627,6 +20808,12 @@ function RedactoPrivacyCenter({
20627
20808
  theme: _theme,
20628
20809
  accessToken,
20629
20810
  refreshToken,
20811
+ token,
20812
+ email,
20813
+ mobile,
20814
+ ucic,
20815
+ organisationUuid,
20816
+ workspaceUuid,
20630
20817
  onError,
20631
20818
  initialPage = "home",
20632
20819
  initialCaseUuid,
@@ -20635,8 +20822,14 @@ function RedactoPrivacyCenter({
20635
20822
  return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(SafeAreaBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(KeyboardProviderCompat, { children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_react_query2.QueryClientProvider, { client: privacyCenterQueryClient, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_react_i18next29.I18nextProvider, { i18n: i18n_default, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ThemeProvider, { slug, baseUrl, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(BaseUrlProvider, { baseUrl, ledgerBaseUrl, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
20636
20823
  AuthProvider,
20637
20824
  {
20638
- accessToken,
20639
- refreshToken,
20825
+ accessToken: accessToken != null ? accessToken : "",
20826
+ refreshToken: refreshToken != null ? refreshToken : "",
20827
+ token,
20828
+ sandboxUcic: ucic,
20829
+ sandboxSubject: email || mobile,
20830
+ organisationUuid,
20831
+ workspaceUuid,
20832
+ slug,
20640
20833
  onError,
20641
20834
  children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(NavigationProvider, { initialPage, initialPendingCaseUuid: initialCaseUuid != null ? initialCaseUuid : null, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(DataAvailabilityProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(PageStatusProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(PrivacyCenterContent, { onBack }) }) }) })
20642
20835
  }