@redacto.io/consent-sdk-react-native 5.0.0-beta.6 → 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.
@@ -1,7 +1,8 @@
1
1
  import {
2
+ SANDBOX_TOKEN_HEADER,
2
3
  __require,
3
4
  languageOptions
4
- } from "./chunk-UVRSRLYW.mjs";
5
+ } from "./chunk-B2TXWC2C.mjs";
5
6
 
6
7
  // src/RedactoPrivacyCenter/RedactoPrivacyCenter.tsx
7
8
  import { useEffect as useEffect20 } from "react";
@@ -9750,6 +9751,33 @@ function useSafeInsets() {
9750
9751
  // src/RedactoPrivacyCenter/context/BaseUrlContext.tsx
9751
9752
  import { createContext, useContext, useMemo } from "react";
9752
9753
 
9754
+ // src/RedactoPrivacyCenter/lib/sandbox.ts
9755
+ var sandboxConfig = null;
9756
+ var setSandboxConfig = (config) => {
9757
+ sandboxConfig = config;
9758
+ };
9759
+ var getSandboxConfig = () => sandboxConfig;
9760
+ var isSandboxMode = () => sandboxConfig !== null;
9761
+ var sandboxAuthHeaders = () => {
9762
+ if (!sandboxConfig) {
9763
+ return null;
9764
+ }
9765
+ return {
9766
+ [SANDBOX_TOKEN_HEADER]: sandboxConfig.token
9767
+ };
9768
+ };
9769
+ var sandboxBodyIdentity = () => {
9770
+ if (!sandboxConfig) {
9771
+ return null;
9772
+ }
9773
+ if (sandboxConfig.ucic) {
9774
+ return { org_user_id: sandboxConfig.ucic };
9775
+ }
9776
+ return sandboxConfig.subject.includes("@") ? { primary_email: sandboxConfig.subject } : { primary_mobile: sandboxConfig.subject };
9777
+ };
9778
+ var sandboxQueryIdentity = () => sandboxBodyIdentity();
9779
+ var sandboxContact = () => sandboxConfig ? sandboxConfig.ucic || sandboxConfig.subject : null;
9780
+
9753
9781
  // src/RedactoPrivacyCenter/api/fetcher.ts
9754
9782
  async function apiFetch(url, options = {}) {
9755
9783
  const { getAuthToken, headers = {}, ...fetchOptions } = options;
@@ -9775,11 +9803,18 @@ async function apiFetch(url, options = {}) {
9775
9803
  }
9776
9804
  }
9777
9805
  if (getAuthToken) {
9778
- const token = await getAuthToken();
9779
- if (token) {
9780
- const trimmedToken = token.trim();
9781
- requestHeaders.set("X-Auth-Token", trimmedToken);
9782
- requestHeaders.set("x-auth-token", trimmedToken);
9806
+ const sandboxHeaders = sandboxAuthHeaders();
9807
+ if (sandboxHeaders) {
9808
+ Object.entries(sandboxHeaders).forEach(([key, value]) => {
9809
+ requestHeaders.set(key, value);
9810
+ });
9811
+ } else {
9812
+ const token = await getAuthToken();
9813
+ if (token) {
9814
+ const trimmedToken = token.trim();
9815
+ requestHeaders.set("X-Auth-Token", trimmedToken);
9816
+ requestHeaders.set("x-auth-token", trimmedToken);
9817
+ }
9783
9818
  }
9784
9819
  }
9785
9820
  const fetchOptionsFinal = {
@@ -9870,14 +9905,29 @@ function arrayBufferToBase64(buffer) {
9870
9905
  return result;
9871
9906
  }
9872
9907
  function createConsentClient(baseUrl, ledgerBaseUrl) {
9873
- const useLedger = Boolean(ledgerBaseUrl);
9908
+ const ledgerConfigured = Boolean(ledgerBaseUrl);
9909
+ const useLedger = () => ledgerConfigured && !isSandboxMode();
9874
9910
  const ledgerBase = (ledgerBaseUrl != null ? ledgerBaseUrl : "").replace(/\/$/, "");
9875
9911
  function ledgerUrl(baseRequest, path) {
9876
- if (!useLedger) {
9912
+ if (!useLedger()) {
9877
9913
  throw new Error("ledgerUrl called without a configured ledgerBaseUrl");
9878
9914
  }
9879
9915
  return `${ledgerBase}/public/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}${path}`;
9880
9916
  }
9917
+ function appendSandboxIdentity(queryParams) {
9918
+ const identity = sandboxQueryIdentity();
9919
+ if (identity) {
9920
+ Object.entries(identity).forEach(([key, value]) => {
9921
+ queryParams.append(key, value);
9922
+ });
9923
+ }
9924
+ }
9925
+ function sandboxIdentitySuffix() {
9926
+ const queryParams = new URLSearchParams();
9927
+ appendSandboxIdentity(queryParams);
9928
+ const queryString = queryParams.toString();
9929
+ return queryString ? `?${queryString}` : "";
9930
+ }
9881
9931
  async function privacyCenterApiFetch(url, options) {
9882
9932
  const { authToken, getAuthToken, headers = {}, ...fetchOptions } = options;
9883
9933
  const requestHeaders = new Headers();
@@ -9901,11 +9951,18 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
9901
9951
  );
9902
9952
  }
9903
9953
  }
9904
- const token = authToken || (getAuthToken ? await getAuthToken() : null);
9905
- if (token) {
9906
- const trimmedToken = token.trim();
9907
- const bearerToken = trimmedToken.startsWith("Bearer ") ? trimmedToken : `Bearer ${trimmedToken}`;
9908
- requestHeaders.set("Authorization", bearerToken);
9954
+ const sandboxHeaders = sandboxAuthHeaders();
9955
+ if (sandboxHeaders) {
9956
+ Object.entries(sandboxHeaders).forEach(([key, value]) => {
9957
+ requestHeaders.set(key, value);
9958
+ });
9959
+ } else {
9960
+ const token = authToken || (getAuthToken ? await getAuthToken() : null);
9961
+ if (token) {
9962
+ const trimmedToken = token.trim();
9963
+ const bearerToken = trimmedToken.startsWith("Bearer ") ? trimmedToken : `Bearer ${trimmedToken}`;
9964
+ requestHeaders.set("Authorization", bearerToken);
9965
+ }
9909
9966
  }
9910
9967
  const fetchOptionsFinal = {
9911
9968
  ...fetchOptions,
@@ -9986,18 +10043,20 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
9986
10043
  async createCaseRequest(baseRequest, payload, authToken, options) {
9987
10044
  const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/case`;
9988
10045
  const { useSessionAuth = false, getAuthToken, ...fetchOptions } = options || {};
10046
+ const contact = sandboxContact();
10047
+ const requestPayload = contact && payload && typeof payload === "object" ? { ...payload, contact } : payload;
9989
10048
  if (useSessionAuth) {
9990
10049
  return apiFetch(url, {
9991
10050
  ...fetchOptions,
9992
10051
  method: "POST",
9993
- body: JSON.stringify(payload),
10052
+ body: JSON.stringify(requestPayload),
9994
10053
  getAuthToken
9995
10054
  });
9996
10055
  }
9997
10056
  return privacyCenterApiFetch(url, {
9998
10057
  ...fetchOptions,
9999
10058
  method: "POST",
10000
- body: JSON.stringify(payload),
10059
+ body: JSON.stringify(requestPayload),
10001
10060
  authToken: authToken || baseRequest.authToken
10002
10061
  });
10003
10062
  },
@@ -10078,9 +10137,10 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10078
10137
  if (params.status) queryParams.append("status", params.status);
10079
10138
  if (params.product_uuid) queryParams.append("product_uuid", params.product_uuid);
10080
10139
  if (params.language) queryParams.append("language", params.language);
10140
+ appendSandboxIdentity(queryParams);
10081
10141
  const queryString = queryParams.toString();
10082
10142
  const consentsSuffix = `/user-consents${queryString ? `?${queryString}` : ""}`;
10083
- const url = useLedger ? ledgerUrl(baseRequest, consentsSuffix) : `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center${consentsSuffix}`;
10143
+ const url = useLedger() ? ledgerUrl(baseRequest, consentsSuffix) : `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center${consentsSuffix}`;
10084
10144
  return privacyCenterApiFetch(url, {
10085
10145
  ...options,
10086
10146
  method: "GET",
@@ -10099,9 +10159,10 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10099
10159
  if (params.search) queryParams.append("search", params.search);
10100
10160
  if (params.language) queryParams.append("language", params.language);
10101
10161
  if (params.nominator_uuid) queryParams.append("nominator_uuid", params.nominator_uuid);
10162
+ appendSandboxIdentity(queryParams);
10102
10163
  const queryString = queryParams.toString();
10103
10164
  const purposesSuffix = `/user-consents/${productUuid}/purposes${queryString ? `?${queryString}` : ""}`;
10104
- const url = useLedger ? ledgerUrl(baseRequest, purposesSuffix) : `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center${purposesSuffix}`;
10165
+ const url = useLedger() ? ledgerUrl(baseRequest, purposesSuffix) : `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center${purposesSuffix}`;
10105
10166
  return privacyCenterApiFetch(url, {
10106
10167
  ...options,
10107
10168
  method: "GET",
@@ -10123,9 +10184,13 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10123
10184
  * used with its `{ purpose_uuid, contact, ... }` payload.
10124
10185
  */
10125
10186
  async manageConsent(baseRequest, purposeId, contact, status, authToken, options, nominatorContact, dataElementUuids, noticeUuid, dataElements, language) {
10126
- if (!useLedger) {
10187
+ if (!useLedger()) {
10127
10188
  const url2 = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/manage-consent?status=${status}`;
10128
- const body2 = { purpose_uuid: purposeId, contact };
10189
+ const sandboxSingleContact = sandboxContact();
10190
+ const body2 = {
10191
+ purpose_uuid: purposeId,
10192
+ contact: sandboxSingleContact != null ? sandboxSingleContact : contact
10193
+ };
10129
10194
  if (nominatorContact) {
10130
10195
  body2.nominator_contact = nominatorContact;
10131
10196
  }
@@ -10188,6 +10253,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10188
10253
  if (offset !== void 0) queryParams.append("offset", offset.toString());
10189
10254
  if (limit !== void 0) queryParams.append("limit", limit.toString());
10190
10255
  if (language) queryParams.append("language", language);
10256
+ appendSandboxIdentity(queryParams);
10191
10257
  const queryString = queryParams.toString();
10192
10258
  const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/activities${queryString ? `?${queryString}` : ""}`;
10193
10259
  return privacyCenterApiFetch(url, {
@@ -10208,9 +10274,10 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10208
10274
  if (params.created_before) queryParams.append("created_before", params.created_before);
10209
10275
  if (params.notice_uuid) queryParams.append("notice_uuid", params.notice_uuid);
10210
10276
  if (params.language) queryParams.append("language", params.language);
10277
+ appendSandboxIdentity(queryParams);
10211
10278
  const queryString = queryParams.toString();
10212
10279
  const receiptsSuffix = `/receipts${queryString ? `?${queryString}` : ""}`;
10213
- const url = useLedger ? ledgerUrl(baseRequest, receiptsSuffix) : `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center${receiptsSuffix}`;
10280
+ const url = useLedger() ? ledgerUrl(baseRequest, receiptsSuffix) : `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center${receiptsSuffix}`;
10214
10281
  return privacyCenterApiFetch(url, {
10215
10282
  ...options,
10216
10283
  method: "GET",
@@ -10224,11 +10291,16 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10224
10291
  * the RN UI writes to a temp file to open/share. 404 => not found.
10225
10292
  */
10226
10293
  async getReceiptPdf(baseRequest, receiptUuid, authToken) {
10227
- const url = useLedger ? ledgerUrl(baseRequest, `/receipts/${receiptUuid}/download`) : `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/receipts/${receiptUuid}/pdf`;
10294
+ const url = useLedger() ? ledgerUrl(baseRequest, `/receipts/${receiptUuid}/download`) : `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/receipts/${receiptUuid}/pdf`;
10228
10295
  const token = authToken || baseRequest.authToken;
10229
10296
  const requestHeaders = new Headers();
10230
10297
  requestHeaders.set("Accept", "application/pdf");
10231
- if (token) {
10298
+ const sandboxHeaders = sandboxAuthHeaders();
10299
+ if (sandboxHeaders) {
10300
+ Object.entries(sandboxHeaders).forEach(([key, value]) => {
10301
+ requestHeaders.set(key, value);
10302
+ });
10303
+ } else if (token) {
10232
10304
  const trimmedToken = token.trim();
10233
10305
  const bearerToken = trimmedToken.startsWith("Bearer ") ? trimmedToken : `Bearer ${trimmedToken}`;
10234
10306
  requestHeaders.set("Authorization", bearerToken);
@@ -10254,6 +10326,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10254
10326
  if (offset !== void 0) queryParams.append("offset", offset.toString());
10255
10327
  if (limit !== void 0) queryParams.append("limit", limit.toString());
10256
10328
  if (language) queryParams.append("language", language);
10329
+ appendSandboxIdentity(queryParams);
10257
10330
  const queryString = queryParams.toString();
10258
10331
  const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/cases?${queryString}`;
10259
10332
  return privacyCenterApiFetch(url, {
@@ -10265,7 +10338,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10265
10338
  * Get case messages (privacy center)
10266
10339
  */
10267
10340
  async getCaseMessages(baseRequest, caseUuid, authToken, options) {
10268
- const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/cases/${caseUuid}/messages`;
10341
+ const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/cases/${caseUuid}/messages${sandboxIdentitySuffix()}`;
10269
10342
  return privacyCenterApiFetch(url, {
10270
10343
  ...options,
10271
10344
  authToken: authToken || baseRequest.authToken
@@ -10275,7 +10348,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10275
10348
  * Send a message in a case (privacy center)
10276
10349
  */
10277
10350
  async sendCaseMessage(baseRequest, caseUuid, body, documentUuids, authToken, options) {
10278
- const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/cases/${caseUuid}/messages`;
10351
+ const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/cases/${caseUuid}/messages${sandboxIdentitySuffix()}`;
10279
10352
  return privacyCenterApiFetch(url, {
10280
10353
  ...options,
10281
10354
  method: "POST",
@@ -10287,7 +10360,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10287
10360
  * Upload a document for a case (privacy center)
10288
10361
  */
10289
10362
  async uploadCaseDocument(baseRequest, caseUuid, formData, authToken, options) {
10290
- const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/cases/${caseUuid}/upload-document`;
10363
+ const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/cases/${caseUuid}/upload-document${sandboxIdentitySuffix()}`;
10291
10364
  return privacyCenterApiFetch(url, {
10292
10365
  ...options,
10293
10366
  method: "POST",
@@ -10320,6 +10393,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10320
10393
  if ((params == null ? void 0 : params.limit) !== void 0) queryParams.append("limit", params.limit.toString());
10321
10394
  if (params == null ? void 0 : params.include_summary) queryParams.append("include_summary", "true");
10322
10395
  if (params == null ? void 0 : params.language) queryParams.append("language", params.language);
10396
+ appendSandboxIdentity(queryParams);
10323
10397
  const queryString = queryParams.toString();
10324
10398
  const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/notifications/${queryString ? `?${queryString}` : ""}`;
10325
10399
  return privacyCenterApiFetch(url, {
@@ -10331,7 +10405,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10331
10405
  * Get notification summary (aggregated counts only)
10332
10406
  */
10333
10407
  async getNotificationSummary(baseRequest, authToken) {
10334
- const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/notifications/summary`;
10408
+ const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/notifications/summary${sandboxIdentitySuffix()}`;
10335
10409
  return privacyCenterApiFetch(url, {
10336
10410
  method: "GET",
10337
10411
  authToken: authToken || baseRequest.authToken
@@ -10341,7 +10415,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10341
10415
  * Get unread notification count (lightweight, for the header badge)
10342
10416
  */
10343
10417
  async getUnreadCount(baseRequest, authToken) {
10344
- const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/notifications/unread-count`;
10418
+ const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/notifications/unread-count${sandboxIdentitySuffix()}`;
10345
10419
  return privacyCenterApiFetch(url, {
10346
10420
  method: "GET",
10347
10421
  authToken: authToken || baseRequest.authToken
@@ -10351,7 +10425,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10351
10425
  * Mark a single notification as read
10352
10426
  */
10353
10427
  async markNotificationRead(baseRequest, notificationUuid, authToken) {
10354
- const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/notifications/${notificationUuid}/read`;
10428
+ const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/notifications/${notificationUuid}/read${sandboxIdentitySuffix()}`;
10355
10429
  return privacyCenterApiFetch(url, {
10356
10430
  method: "PATCH",
10357
10431
  authToken: authToken || baseRequest.authToken
@@ -10361,7 +10435,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10361
10435
  * Mark all notifications as read
10362
10436
  */
10363
10437
  async markAllNotificationsRead(baseRequest, authToken) {
10364
- const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/notifications/mark-all-read`;
10438
+ const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/notifications/mark-all-read${sandboxIdentitySuffix()}`;
10365
10439
  return privacyCenterApiFetch(url, {
10366
10440
  method: "POST",
10367
10441
  authToken: authToken || baseRequest.authToken
@@ -10371,7 +10445,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10371
10445
  * Acknowledge a notification (sets is_read and is_acknowledged to true)
10372
10446
  */
10373
10447
  async acknowledgeNotification(baseRequest, notificationUuid, authToken) {
10374
- const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/notifications/${notificationUuid}/acknowledge`;
10448
+ const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center/notifications/${notificationUuid}/acknowledge${sandboxIdentitySuffix()}`;
10375
10449
  return privacyCenterApiFetch(url, {
10376
10450
  method: "POST",
10377
10451
  authToken: authToken || baseRequest.authToken
@@ -11564,6 +11638,10 @@ var compareEmails = (email1, email2) => {
11564
11638
  return decodeURIComponent(email1.trim()).toLowerCase() === email2.trim().toLowerCase();
11565
11639
  };
11566
11640
  var ensureValidToken = async (organizationId, workspaceId, _slug, authContext, consentClient) => {
11641
+ const sandbox = getSandboxConfig();
11642
+ if (sandbox) {
11643
+ return sandbox.token;
11644
+ }
11567
11645
  const accessToken = (authContext == null ? void 0 : authContext.accessToken) || getStoredValue("access_token");
11568
11646
  if (accessToken && typeof accessToken === "string" && accessToken.trim() !== "" && !isJwtExpired(accessToken, TOKEN_EXPIRY_BUFFER_SECONDS)) {
11569
11647
  return accessToken;
@@ -11701,15 +11779,73 @@ function syncJwtDataToStore(token) {
11701
11779
  if (authData.workspaceId) setStoredValue("pc_workspace_id", authData.workspaceId);
11702
11780
  return authData;
11703
11781
  }
11704
- function AuthProvider({ children, accessToken: initialAccessToken, refreshToken: initialRefreshToken, onError }) {
11705
- const initialAuth = extractJwtAuthData(initialAccessToken);
11782
+ function configureSandbox(props) {
11783
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
11784
+ const token = (_a3 = props.token) == null ? void 0 : _a3.trim();
11785
+ if (!token) {
11786
+ setSandboxConfig(null);
11787
+ return null;
11788
+ }
11789
+ const organisationUuid = (_c = (_b = props.organisationUuid) == null ? void 0 : _b.trim()) != null ? _c : "";
11790
+ const workspaceUuid = (_e = (_d = props.workspaceUuid) == null ? void 0 : _d.trim()) != null ? _e : "";
11791
+ const ucic = (_g = (_f = props.sandboxUcic) == null ? void 0 : _f.trim()) != null ? _g : "";
11792
+ const subject = (_i = (_h = props.sandboxSubject) == null ? void 0 : _h.trim()) != null ? _i : "";
11793
+ const slug = (_k = (_j = props.slug) == null ? void 0 : _j.trim()) != null ? _k : "";
11794
+ if (!organisationUuid || !workspaceUuid) {
11795
+ throw new Error("Sandbox mode requires organisationUuid and workspaceUuid props");
11796
+ }
11797
+ if (!ucic && !subject) {
11798
+ throw new Error("Sandbox mode requires a UCIC, email, or mobile");
11799
+ }
11800
+ setSandboxConfig({
11801
+ token,
11802
+ ucic: ucic || void 0,
11803
+ subject,
11804
+ organisationUuid,
11805
+ workspaceUuid,
11806
+ slug
11807
+ });
11808
+ const contact = ucic || subject;
11809
+ setStoredValue("access_token", token);
11810
+ if (organisationUuid) setStoredValue("pc_org_id", organisationUuid);
11811
+ if (workspaceUuid) setStoredValue("pc_workspace_id", workspaceUuid);
11812
+ if (contact) setStoredValue("email", contact);
11813
+ return {
11814
+ email: contact || null,
11815
+ organizationId: organisationUuid || null,
11816
+ workspaceId: workspaceUuid || null,
11817
+ organizationName: null
11818
+ };
11819
+ }
11820
+ function AuthProvider(props) {
11821
+ const {
11822
+ children,
11823
+ accessToken: initialAccessToken,
11824
+ refreshToken: initialRefreshToken,
11825
+ token: sandboxToken,
11826
+ sandboxUcic,
11827
+ sandboxSubject,
11828
+ organisationUuid,
11829
+ workspaceUuid,
11830
+ slug,
11831
+ onError
11832
+ } = props;
11833
+ const [sandboxAuth] = useState(() => configureSandbox(props));
11834
+ const sandboxActive = sandboxAuth !== null;
11835
+ const initialAuth = sandboxAuth != null ? sandboxAuth : extractJwtAuthData(initialAccessToken);
11706
11836
  const [accessToken, setAccessToken] = useState(() => {
11837
+ if (sandboxActive) {
11838
+ return sandboxToken != null ? sandboxToken : "";
11839
+ }
11707
11840
  if (initialAccessToken && initialAccessToken.trim() !== "") {
11708
11841
  syncJwtDataToStore(initialAccessToken);
11709
11842
  }
11710
11843
  return initialAccessToken;
11711
11844
  });
11712
11845
  const [refreshToken, setRefreshToken] = useState(() => {
11846
+ if (sandboxActive) {
11847
+ return "";
11848
+ }
11713
11849
  if (initialRefreshToken && initialRefreshToken.trim() !== "") {
11714
11850
  setStoredValue("refresh_token", initialRefreshToken);
11715
11851
  }
@@ -11720,6 +11856,20 @@ function AuthProvider({ children, accessToken: initialAccessToken, refreshToken:
11720
11856
  const [workspaceId, setWorkspaceId] = useState(initialAuth.workspaceId);
11721
11857
  const [organizationName, setOrganizationName] = useState(initialAuth.organizationName);
11722
11858
  useEffect(() => {
11859
+ if (!sandboxActive) {
11860
+ return;
11861
+ }
11862
+ const seeded = configureSandbox(props);
11863
+ if (seeded) {
11864
+ setEmail(seeded.email);
11865
+ setOrganizationId(seeded.organizationId);
11866
+ setWorkspaceId(seeded.workspaceId);
11867
+ setOrganizationName(seeded.organizationName);
11868
+ }
11869
+ return () => setSandboxConfig(null);
11870
+ }, [sandboxActive, sandboxToken, sandboxUcic, sandboxSubject, organisationUuid, workspaceUuid, slug]);
11871
+ useEffect(() => {
11872
+ if (sandboxActive) return;
11723
11873
  if (accessToken) {
11724
11874
  const authData = syncJwtDataToStore(accessToken);
11725
11875
  setEmail(authData.email);
@@ -11727,11 +11877,13 @@ function AuthProvider({ children, accessToken: initialAccessToken, refreshToken:
11727
11877
  setWorkspaceId(authData.workspaceId);
11728
11878
  setOrganizationName(authData.organizationName);
11729
11879
  }
11730
- }, [accessToken]);
11880
+ }, [accessToken, sandboxActive]);
11731
11881
  useEffect(() => {
11882
+ if (sandboxActive) return;
11732
11883
  if (refreshToken) setStoredValue("refresh_token", refreshToken);
11733
- }, [refreshToken]);
11884
+ }, [refreshToken, sandboxActive]);
11734
11885
  useEffect(() => {
11886
+ if (sandboxActive) return;
11735
11887
  setAccessToken(initialAccessToken);
11736
11888
  if (initialAccessToken && initialAccessToken.trim() !== "") {
11737
11889
  const authData = syncJwtDataToStore(initialAccessToken);
@@ -11740,10 +11892,11 @@ function AuthProvider({ children, accessToken: initialAccessToken, refreshToken:
11740
11892
  setWorkspaceId(authData.workspaceId);
11741
11893
  setOrganizationName(authData.organizationName);
11742
11894
  }
11743
- }, [initialAccessToken]);
11895
+ }, [initialAccessToken, sandboxActive]);
11744
11896
  useEffect(() => {
11897
+ if (sandboxActive) return;
11745
11898
  setRefreshToken(initialRefreshToken);
11746
- }, [initialRefreshToken]);
11899
+ }, [initialRefreshToken, sandboxActive]);
11747
11900
  const updateTokens = useCallback((newAccessToken, newRefreshToken) => {
11748
11901
  setAccessToken(newAccessToken);
11749
11902
  if (newRefreshToken) setRefreshToken(newRefreshToken);
@@ -14138,7 +14291,7 @@ import { useTranslation as useTranslation10 } from "react-i18next";
14138
14291
 
14139
14292
  // src/RedactoPrivacyCenter/lib/consentManagerUtils.ts
14140
14293
  function purposeItemToUserConsent(purpose, group) {
14141
- var _a3, _b, _c, _d;
14294
+ var _a3, _b, _c, _d, _e;
14142
14295
  return {
14143
14296
  purpose_uuid: purpose.purpose_uuid,
14144
14297
  purpose: purpose.name,
@@ -14152,6 +14305,7 @@ function purposeItemToUserConsent(purpose, group) {
14152
14305
  product_name: group.product_name,
14153
14306
  product_description: group.product_description,
14154
14307
  nominator_info: (_d = group.nominator) != null ? _d : void 0,
14308
+ revoke_warning_message: (_e = purpose.revoke_warning_message) != null ? _e : null,
14155
14309
  notice_uuid: purpose.notice_uuid
14156
14310
  };
14157
14311
  }
@@ -14419,7 +14573,7 @@ var ModifyConsentModal = ({
14419
14573
  action: "revoke",
14420
14574
  buttonLabel: t("revokeConsent"),
14421
14575
  buttonColor: colors.error,
14422
- warningMessage: t("revokeConsentWarning"),
14576
+ warningMessage: selectedRecord.revoke_warning_message || t("revokeConsentWarning"),
14423
14577
  description: nominatorLabel ? t("aboutToModifyConsentOnBehalf", { nominator: nominatorLabel }) : t("aboutToModifyConsent")
14424
14578
  };
14425
14579
  }
@@ -20658,6 +20812,12 @@ function RedactoPrivacyCenter({
20658
20812
  theme: _theme,
20659
20813
  accessToken,
20660
20814
  refreshToken,
20815
+ token,
20816
+ email,
20817
+ mobile,
20818
+ ucic,
20819
+ organisationUuid,
20820
+ workspaceUuid,
20661
20821
  onError,
20662
20822
  initialPage = "home",
20663
20823
  initialCaseUuid,
@@ -20666,8 +20826,14 @@ function RedactoPrivacyCenter({
20666
20826
  return /* @__PURE__ */ jsx64(SafeAreaBoundary, { children: /* @__PURE__ */ jsx64(KeyboardProviderCompat, { children: /* @__PURE__ */ jsx64(QueryClientProvider, { client: privacyCenterQueryClient, children: /* @__PURE__ */ jsx64(I18nextProvider, { i18n: i18n_default, children: /* @__PURE__ */ jsx64(ThemeProvider, { slug, baseUrl, children: /* @__PURE__ */ jsx64(BaseUrlProvider, { baseUrl, ledgerBaseUrl, children: /* @__PURE__ */ jsx64(
20667
20827
  AuthProvider,
20668
20828
  {
20669
- accessToken,
20670
- refreshToken,
20829
+ accessToken: accessToken != null ? accessToken : "",
20830
+ refreshToken: refreshToken != null ? refreshToken : "",
20831
+ token,
20832
+ sandboxUcic: ucic,
20833
+ sandboxSubject: email || mobile,
20834
+ organisationUuid,
20835
+ workspaceUuid,
20836
+ slug,
20671
20837
  onError,
20672
20838
  children: /* @__PURE__ */ jsx64(NavigationProvider, { initialPage, initialPendingCaseUuid: initialCaseUuid != null ? initialCaseUuid : null, children: /* @__PURE__ */ jsx64(DataAvailabilityProvider, { children: /* @__PURE__ */ jsx64(PageStatusProvider, { children: /* @__PURE__ */ jsx64(PrivacyCenterContent, { onBack }) }) }) })
20673
20839
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redacto.io/consent-sdk-react-native",
3
- "version": "5.0.0-beta.6",
3
+ "version": "5.0.0-beta.7",
4
4
  "description": "React Native SDK for integrating Redacto consent notices and privacy center in mobile apps.",
5
5
  "keywords": [
6
6
  "consent",