@redacto.io/consent-sdk-react 10.4.0-beta.1 → 11.0.0-beta.2

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.
@@ -15,10 +15,14 @@ import {
15
15
  isSafeCustomCss,
16
16
  loadNoticeWebfont,
17
17
  resolveAppearance,
18
+ resolveEndpoints,
18
19
  useIsomorphicLayoutEffect,
19
20
  useMediaQuery,
21
+ useResolvedEndpoints,
22
+ warnEndpointUsage,
23
+ warnSlugDeprecated,
20
24
  withIdempotencyKey
21
- } from "./chunk-DGMUTOWJ.mjs";
25
+ } from "./chunk-W45JQYDG.mjs";
22
26
  import {
23
27
  INHERIT_FONT_FAMILY,
24
28
  resolveNoticeFontFamily
@@ -9120,36 +9124,35 @@ var isJwtExpired = (token, bufferSeconds = 5 * 60) => {
9120
9124
  return true;
9121
9125
  }
9122
9126
  };
9123
- var isUserAuthenticated = (expectedSlug) => {
9127
+ var isUserAuthenticated = (_expectedSlug) => {
9124
9128
  if (typeof window === "undefined") return false;
9125
9129
  const accessToken = sessionStorage.getItem("access_token");
9126
9130
  const email = sessionStorage.getItem("email");
9127
- const orgSlug = sessionStorage.getItem("pc_org_slug");
9128
- if (!accessToken || !email || !orgSlug) {
9129
- return false;
9130
- }
9131
- return orgSlug === expectedSlug;
9131
+ return Boolean(accessToken && email);
9132
9132
  };
9133
- var getInitialState = (slug) => {
9133
+ var getInitialState = (_slug) => {
9134
9134
  if (typeof window === "undefined") return true;
9135
- return !isUserAuthenticated(slug);
9135
+ return !isUserAuthenticated();
9136
9136
  };
9137
- var checkAndRefreshAuth = async (expectedSlug, organizationId, workspaceId, consentClient) => {
9137
+ var isSessionForOrganisation = (organizationId) => {
9138
+ const storedOrgId = sessionStorage.getItem("pc_org_id");
9139
+ return Boolean(storedOrgId) && (!organizationId || storedOrgId === organizationId);
9140
+ };
9141
+ var checkAndRefreshAuth = async (_expectedSlug, organizationId, workspaceId, consentClient) => {
9138
9142
  if (typeof window === "undefined") return false;
9139
9143
  if (getSandboxConfig()) {
9140
9144
  return true;
9141
9145
  }
9142
9146
  const accessToken = sessionStorage.getItem("access_token");
9143
9147
  const email = sessionStorage.getItem("email");
9144
- const orgSlug = sessionStorage.getItem("pc_org_slug");
9145
- if (orgSlug && orgSlug !== expectedSlug) {
9148
+ if (!isSessionForOrganisation(organizationId)) {
9146
9149
  return false;
9147
9150
  }
9148
9151
  const needsRefresh = !accessToken || accessToken && isJwtExpired(accessToken, TOKEN_EXPIRY_BUFFER_SECONDS);
9149
- if (!needsRefresh && accessToken && email && orgSlug && orgSlug === expectedSlug) {
9152
+ if (!needsRefresh && accessToken && email) {
9150
9153
  return true;
9151
9154
  }
9152
- if (needsRefresh && email && orgSlug === expectedSlug) {
9155
+ if (needsRefresh && email) {
9153
9156
  const orgId = organizationId || sessionStorage.getItem("pc_org_id") || "";
9154
9157
  const wsId = workspaceId || sessionStorage.getItem("pc_workspace_id") || "";
9155
9158
  if (!orgId || !wsId) {
@@ -9248,7 +9251,7 @@ var signOutPrivacyCenter = () => {
9248
9251
  removeStorage(REFRESH_TOKEN_STORAGE_KEY);
9249
9252
  clearLegacyRefreshTokenCookie();
9250
9253
  };
9251
- var ensureValidToken = async (organizationId, workspaceId, slug, authContext, consentClient) => {
9254
+ var ensureValidToken = async (organizationId, workspaceId, _slug, authContext, consentClient) => {
9252
9255
  if (typeof window === "undefined") return null;
9253
9256
  const sandbox = getSandboxConfig();
9254
9257
  if (sandbox) {
@@ -9273,7 +9276,7 @@ var ensureValidToken = async (organizationId, workspaceId, slug, authContext, co
9273
9276
  return newToken;
9274
9277
  }
9275
9278
  isRefreshing = true;
9276
- refreshPromise = performTokenRefresh(organizationId, workspaceId, slug, authContext, consentClient);
9279
+ refreshPromise = performTokenRefresh(organizationId, workspaceId, authContext, consentClient);
9277
9280
  try {
9278
9281
  const newToken = await refreshPromise;
9279
9282
  return newToken;
@@ -9282,7 +9285,7 @@ var ensureValidToken = async (organizationId, workspaceId, slug, authContext, co
9282
9285
  refreshPromise = null;
9283
9286
  }
9284
9287
  };
9285
- var performTokenRefresh = async (organizationId, workspaceId, _slug, authContext, consentClient) => {
9288
+ var performTokenRefresh = async (organizationId, workspaceId, authContext, consentClient) => {
9286
9289
  var _a, _b, _c, _d, _e, _f, _g;
9287
9290
  const orgId = organizationId || sessionStorage.getItem("pc_org_id") || "";
9288
9291
  const wsId = workspaceId || sessionStorage.getItem("pc_workspace_id") || "";
@@ -9886,13 +9889,15 @@ var seedSessionStorage = (data) => {
9886
9889
  return;
9887
9890
  }
9888
9891
  if (data.accessToken) sessionStorage.setItem("access_token", data.accessToken);
9892
+ if (data.orgId && !data.workspaceId && sessionStorage.getItem("pc_org_id") !== data.orgId) {
9893
+ sessionStorage.removeItem("pc_workspace_id");
9894
+ }
9889
9895
  if (data.orgId) sessionStorage.setItem("pc_org_id", data.orgId);
9890
9896
  if (data.workspaceId) sessionStorage.setItem("pc_workspace_id", data.workspaceId);
9891
- if (data.slug) sessionStorage.setItem("pc_org_slug", data.slug);
9892
9897
  if (data.contact) sessionStorage.setItem("email", data.contact);
9893
9898
  };
9894
9899
  var configureSandbox = (props) => {
9895
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
9900
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
9896
9901
  const token = (_a = props.token) == null ? void 0 : _a.trim();
9897
9902
  if (!token) {
9898
9903
  setSandboxConfig(null);
@@ -9903,21 +9908,18 @@ var configureSandbox = (props) => {
9903
9908
  const ucic = (_g = (_f = props.sandboxUcic) == null ? void 0 : _f.trim()) != null ? _g : "";
9904
9909
  const email = (_i = (_h = props.sandboxEmail) == null ? void 0 : _h.trim()) != null ? _i : "";
9905
9910
  const mobile = (_k = (_j = props.sandboxMobile) == null ? void 0 : _j.trim()) != null ? _k : "";
9906
- const slug = (_m = (_l = props.slug) == null ? void 0 : _l.trim()) != null ? _m : "";
9907
9911
  setSandboxConfig({
9908
9912
  token,
9909
9913
  ucic: ucic || void 0,
9910
9914
  email: email || void 0,
9911
9915
  mobile: mobile || void 0,
9912
9916
  organisationUuid,
9913
- workspaceUuid,
9914
- slug
9917
+ workspaceUuid
9915
9918
  });
9916
9919
  seedSessionStorage({
9917
9920
  accessToken: token,
9918
9921
  orgId: organisationUuid,
9919
9922
  workspaceId: workspaceUuid,
9920
- slug,
9921
9923
  // The principal precedence (UCIC > email > mobile) the server also applies.
9922
9924
  contact: ucic || email || mobile
9923
9925
  });
@@ -9933,7 +9935,6 @@ var syncJwtDataToSessionStorage = (accessToken) => {
9933
9935
  seedSessionStorage({
9934
9936
  orgId: typeof decoded.organisation_uuid === "string" ? decoded.organisation_uuid : void 0,
9935
9937
  workspaceId: typeof decoded.workspace_uuid === "string" ? decoded.workspace_uuid : void 0,
9936
- slug: typeof decoded.organisation_slug === "string" ? decoded.organisation_slug : void 0,
9937
9938
  contact: typeof contact === "string" ? contact : void 0
9938
9939
  });
9939
9940
  };
@@ -9948,7 +9949,6 @@ var AuthProvider = (props) => {
9948
9949
  sandboxMobile,
9949
9950
  organisationUuid,
9950
9951
  workspaceUuid,
9951
- slug,
9952
9952
  onError
9953
9953
  } = props;
9954
9954
  const [sandboxActive] = useState(() => configureSandbox(props));
@@ -10032,7 +10032,7 @@ var AuthProvider = (props) => {
10032
10032
  }
10033
10033
  configureSandbox(props);
10034
10034
  return () => setSandboxConfig(null);
10035
- }, [sandboxActive, sandboxToken, sandboxUcic, sandboxEmail, sandboxMobile, organisationUuid, workspaceUuid, slug]);
10035
+ }, [sandboxActive, sandboxToken, sandboxUcic, sandboxEmail, sandboxMobile, organisationUuid, workspaceUuid]);
10036
10036
  const updateTokens = useCallback2((newAccessToken, newRefreshToken) => {
10037
10037
  setAccessToken(newAccessToken);
10038
10038
  if (newRefreshToken) {
@@ -10079,9 +10079,13 @@ import { createContext as createContext4, useContext as useContext4, useMemo as
10079
10079
 
10080
10080
  // src/RedactoPrivacyCenter/api/client.ts
10081
10081
  function createConsentClient(baseUrl, ledgerBaseUrl) {
10082
- const ledgerConfigured = Boolean(ledgerBaseUrl);
10082
+ var _a;
10083
+ warnEndpointUsage(baseUrl, ledgerBaseUrl, { hasBuiltInDefault: false });
10084
+ const endpoints = resolveEndpoints(baseUrl, ledgerBaseUrl);
10085
+ const consentBaseUrl = endpoints.baseUrl;
10086
+ const ledgerConfigured = Boolean(endpoints.ledgerBaseUrl);
10083
10087
  const useLedger = () => ledgerConfigured;
10084
- const ledgerBase = (ledgerBaseUrl != null ? ledgerBaseUrl : "").replace(/\/$/, "");
10088
+ const ledgerBase = ((_a = endpoints.ledgerBaseUrl) != null ? _a : "").replace(/\/$/, "");
10085
10089
  async function privacyCenterApiFetch(url, options) {
10086
10090
  const { authToken, getAuthToken, headers = {}, ...fetchOptions } = options;
10087
10091
  const requestHeaders = new Headers();
@@ -10179,7 +10183,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10179
10183
  }
10180
10184
  }
10181
10185
  function privacyCenterUrl(baseRequest, path) {
10182
- return `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center${path}`;
10186
+ return `${consentBaseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/dsar/privacy-center${path}`;
10183
10187
  }
10184
10188
  function ledgerUrl(baseRequest, path) {
10185
10189
  if (!useLedger()) {
@@ -10281,7 +10285,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10281
10285
  * `channel: "sms"`.
10282
10286
  */
10283
10287
  async createOtp(organisationId, workspaceId, email, options, channel = "email") {
10284
- const url = `${baseUrl}/public/organisations/${organisationId}/workspaces/${workspaceId}/otp/create`;
10288
+ const url = `${consentBaseUrl}/public/organisations/${organisationId}/workspaces/${workspaceId}/otp/create`;
10285
10289
  return apiFetch(url, {
10286
10290
  ...options,
10287
10291
  method: "POST",
@@ -10299,7 +10303,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10299
10303
  * then rejects it with 403 "Token scope is not permitted".
10300
10304
  */
10301
10305
  async verifyOtp(organisationId, workspaceId, otpId, otp, options, purpose = "login") {
10302
- const url = `${baseUrl}/public/organisations/${organisationId}/workspaces/${workspaceId}/otp/verify`;
10306
+ const url = `${consentBaseUrl}/public/organisations/${organisationId}/workspaces/${workspaceId}/otp/verify`;
10303
10307
  return apiFetch(url, {
10304
10308
  ...options,
10305
10309
  method: "POST",
@@ -10310,7 +10314,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10310
10314
  * Exchange one-time token for JWT tokens (public)
10311
10315
  */
10312
10316
  async exchangeToken(token) {
10313
- const url = `${baseUrl}/public/tokens/token-exchange?token=${encodeURIComponent(token)}`;
10317
+ const url = `${consentBaseUrl}/public/tokens/token-exchange?token=${encodeURIComponent(token)}`;
10314
10318
  const response = await fetch(url, {
10315
10319
  method: "GET",
10316
10320
  headers: { Accept: "application/json" }
@@ -10331,7 +10335,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10331
10335
  * Refresh OTP token (public)
10332
10336
  */
10333
10337
  async refreshOtpToken(organisationId, workspaceId, refreshToken, options) {
10334
- const url = `${baseUrl}/public/organisations/${organisationId}/workspaces/${workspaceId}/otp/refresh`;
10338
+ const url = `${consentBaseUrl}/public/organisations/${organisationId}/workspaces/${workspaceId}/otp/refresh`;
10335
10339
  return apiFetch(url, {
10336
10340
  ...options,
10337
10341
  method: "POST",
@@ -10342,7 +10346,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10342
10346
  * Get products
10343
10347
  */
10344
10348
  async getProducts(baseRequest, skip = 0, limit = 10, options) {
10345
- const url = `${baseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/notice-management/products/?skip=${skip}&limit=${limit}`;
10349
+ const url = `${consentBaseUrl}/organisations/${baseRequest.organisationUuid}/workspaces/${baseRequest.workspaceUuid}/notice-management/products/?skip=${skip}&limit=${limit}`;
10346
10350
  return apiFetch(url, {
10347
10351
  ...options,
10348
10352
  getAuthToken: async () => baseRequest.authToken
@@ -10434,7 +10438,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10434
10438
  * used with its `{ purpose_uuid, contact, ... }` payload.
10435
10439
  */
10436
10440
  async manageConsent(baseRequest, purposeId, contact, status, authToken, options, nominatorContact, dataElementUuids, productUuid, noticeUuid, dataElements, language, nominatorUuid) {
10437
- var _a;
10441
+ var _a2;
10438
10442
  if (!useLedger()) {
10439
10443
  const url2 = privacyCenterUrl(
10440
10444
  baseRequest,
@@ -10484,7 +10488,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10484
10488
  notice_uuid: noticeUuid,
10485
10489
  // Sandbox has no JWT, so the ledger resolves the acting test principal
10486
10490
  // from this identity in the body; null (spread no-op) on the live JWT path.
10487
- ...(_a = sandboxBodyIdentity()) != null ? _a : {},
10491
+ ...(_a2 = sandboxBodyIdentity()) != null ? _a2 : {},
10488
10492
  // Pins the action to the card the user acted on. Without it the ledger
10489
10493
  // scopes by the notice and applies the answer to every product the
10490
10494
  // notice covers, so revoking a purpose held on two products withdrew
@@ -10835,17 +10839,21 @@ var BaseUrlProvider = ({
10835
10839
  baseUrl,
10836
10840
  ledgerBaseUrl
10837
10841
  }) => {
10842
+ const endpoints = useResolvedEndpoints(baseUrl, ledgerBaseUrl, {
10843
+ hasBuiltInDefault: false
10844
+ });
10838
10845
  const consentClient = useMemo3(
10839
10846
  () => createConsentClient(baseUrl, ledgerBaseUrl),
10840
10847
  [baseUrl, ledgerBaseUrl]
10841
10848
  );
10842
10849
  const value = useMemo3(
10843
10850
  () => ({
10844
- baseUrl,
10845
- ledgerBaseUrl,
10846
- consentClient
10851
+ baseUrl: endpoints.baseUrl,
10852
+ ledgerBaseUrl: endpoints.ledgerBaseUrl,
10853
+ consentClient,
10854
+ apiHost: endpoints.apiHost
10847
10855
  }),
10848
- [baseUrl, ledgerBaseUrl, consentClient]
10856
+ [endpoints, consentClient]
10849
10857
  );
10850
10858
  return /* @__PURE__ */ jsx4(BaseUrlContext.Provider, { value, children });
10851
10859
  };
@@ -13900,11 +13908,15 @@ function originOf(url) {
13900
13908
  return match ? match[0] : "";
13901
13909
  }
13902
13910
  function userServiceBaseUrl(consentBaseUrl) {
13911
+ const endpoints = resolveEndpoints(consentBaseUrl);
13912
+ if (endpoints.mode === "host") {
13913
+ return endpoints.apiHost + USER_SERVICE_PATH;
13914
+ }
13903
13915
  const origin = originOf(consentBaseUrl) || originOf(DEFAULT_CONSENT_API_BASE_URL);
13904
13916
  return origin + USER_SERVICE_PATH;
13905
13917
  }
13906
- async function fetchOrgBranding(slug, baseUrl) {
13907
- const url = `${userServiceBaseUrl(baseUrl)}/public/org-branding/by-slug/${encodeURIComponent(slug)}`;
13918
+ async function fetchOrgBrandingForOrganisation(organisationUuid, baseUrl) {
13919
+ const url = `${userServiceBaseUrl(baseUrl)}/public/org-branding/${encodeURIComponent(organisationUuid)}`;
13908
13920
  return apiFetch(url, { method: "GET" });
13909
13921
  }
13910
13922
 
@@ -14274,7 +14286,6 @@ var DEFAULT_CONTEXT = {
14274
14286
  status: "idle",
14275
14287
  isCustomised: false,
14276
14288
  organisation: { organisationUuid: null, workspaceUuid: null, status: "failed" },
14277
- slug: "",
14278
14289
  builtInSignIn: false,
14279
14290
  brandContact: EMPTY_BRAND_CONTACT
14280
14291
  };
@@ -14301,18 +14312,20 @@ var withIdentityOverride = (branding, settings) => {
14301
14312
  };
14302
14313
  var BrandingProvider = ({
14303
14314
  children,
14304
- slug,
14305
14315
  baseUrl
14306
14316
  }) => {
14307
14317
  var _a;
14308
14318
  const [branding, setBranding] = useState11(null);
14309
- const { branding: brandingSettings } = usePrivacyCenterSettings();
14319
+ const { settings, organisation } = usePrivacyCenterSettingsContext();
14320
+ const brandingSettings = settings.branding;
14321
+ const organisationUuid = organisation.organisationUuid;
14310
14322
  const scope = usePrivacyCenterScope();
14311
14323
  const scopeId = (_a = scope == null ? void 0 : scope.id) != null ? _a : null;
14312
14324
  useEffect11(() => {
14313
- if (!slug) return;
14325
+ setBranding(null);
14326
+ if (!organisationUuid) return;
14314
14327
  let cancelled = false;
14315
- fetchOrgBranding(slug, baseUrl).then((data) => {
14328
+ fetchOrgBrandingForOrganisation(organisationUuid, baseUrl).then((data) => {
14316
14329
  if (!cancelled) setBranding(data);
14317
14330
  }).catch((error) => {
14318
14331
  console.warn("[RedactoPrivacyCenter] org branding fetch failed:", error);
@@ -14320,7 +14333,7 @@ var BrandingProvider = ({
14320
14333
  return () => {
14321
14334
  cancelled = true;
14322
14335
  };
14323
- }, [slug, baseUrl]);
14336
+ }, [organisationUuid, baseUrl]);
14324
14337
  const themeVars = useMemo5(
14325
14338
  () => ({
14326
14339
  ...(branding == null ? void 0 : branding.theme) ? brandingThemeVars(branding.theme) : {},
@@ -14380,13 +14393,12 @@ var resolvePlaceholders = (text2, context) => {
14380
14393
  };
14381
14394
 
14382
14395
  // src/RedactoPrivacyCenter/settings/copy.ts
14383
- var nameFromSlug = (slug) => slug.split("-").filter(Boolean).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
14384
14396
  var usePlaceholderContext = () => {
14385
14397
  var _a, _b;
14386
14398
  const branding = useBranding();
14387
- const { slug, brandContact } = usePrivacyCenterSettingsContext();
14399
+ const { brandContact } = usePrivacyCenterSettingsContext();
14388
14400
  const organizationName = (_b = (_a = useContext10(OrganizationContext)) == null ? void 0 : _a.organization) == null ? void 0 : _b.name;
14389
- const brand = (branding == null ? void 0 : branding.brand_name) || organizationName || nameFromSlug(slug);
14401
+ const brand = (branding == null ? void 0 : branding.brand_name) || organizationName || "";
14390
14402
  const legal = brandContact.legal_entity_name || (branding == null ? void 0 : branding.legal_name) || null;
14391
14403
  return useMemo6(() => ({ brand, legal }), [brand, legal]);
14392
14404
  };
@@ -17952,9 +17964,8 @@ var INVALID_CONTACT_KEYS = {
17952
17964
  email: "signInInvalidContactEmail",
17953
17965
  sms: "signInInvalidContactSms"
17954
17966
  };
17955
- var seedSession = (slug, organisationUuid, workspaceUuid, sent) => {
17967
+ var seedSession = (organisationUuid, workspaceUuid, sent) => {
17956
17968
  try {
17957
- sessionStorage.setItem("pc_org_slug", slug);
17958
17969
  sessionStorage.setItem("pc_org_id", organisationUuid);
17959
17970
  sessionStorage.setItem("pc_workspace_id", workspaceUuid);
17960
17971
  if (sent.channel === "email") {
@@ -17963,7 +17974,7 @@ var seedSession = (slug, organisationUuid, workspaceUuid, sent) => {
17963
17974
  } catch {
17964
17975
  }
17965
17976
  };
17966
- function PrivacyCenterSignIn({ slug }) {
17977
+ function PrivacyCenterSignIn() {
17967
17978
  var _a;
17968
17979
  const { t } = useTranslation22();
17969
17980
  const { settings, organisation } = usePrivacyCenterSettingsContext();
@@ -17978,7 +17989,6 @@ function PrivacyCenterSignIn({ slug }) {
17978
17989
  const countdown = useCountdown();
17979
17990
  const { organisationUuid, workspaceUuid } = organisation;
17980
17991
  const orgUnavailable = organisation.status === "failed";
17981
- const orgPending = organisation.status === "resolving";
17982
17992
  const sendCode = useCallback18(
17983
17993
  async (contact, channel) => {
17984
17994
  const response = await consentClient.createOtp(
@@ -18044,7 +18054,7 @@ function PrivacyCenterSignIn({ slug }) {
18044
18054
  setError(t("otpErrorFallback"));
18045
18055
  return;
18046
18056
  }
18047
- seedSession(slug, organisationUuid, workspaceUuid, sent);
18057
+ seedSession(organisationUuid, workspaceUuid, sent);
18048
18058
  updateTokens(accessToken, (_a2 = result == null ? void 0 : result.refresh_token) != null ? _a2 : void 0);
18049
18059
  } catch (verifyError) {
18050
18060
  setError(t(otpErrorKey(verifyError)));
@@ -18101,7 +18111,7 @@ function PrivacyCenterSignIn({ slug }) {
18101
18111
  {
18102
18112
  initialValue: typedContact,
18103
18113
  initialCountryCode: (_a = sent == null ? void 0 : sent.countryCode) != null ? _a : null,
18104
- busy: busy || orgPending,
18114
+ busy,
18105
18115
  disabled: orgUnavailable,
18106
18116
  error: error != null ? error : orgUnavailable ? t("signInOrgUnavailable") : null,
18107
18117
  onSubmit: (value, countryCode) => void handleContact(value, countryCode),
@@ -18209,7 +18219,7 @@ function PrivacyCenterLayout({ settings, ...props }) {
18209
18219
  }
18210
18220
  function PrivacyCenterLayoutContent({
18211
18221
  children,
18212
- slug,
18222
+ slug = "",
18213
18223
  onBack
18214
18224
  }) {
18215
18225
  const { consentClient } = useBaseUrl();
@@ -18221,39 +18231,38 @@ function PrivacyCenterLayoutContent({
18221
18231
  const [isLoadingOrg, setIsLoadingOrg] = useState25(true);
18222
18232
  const hasRedirectedRef = useRef15(false);
18223
18233
  const authCheckInProgressRef = useRef15(false);
18234
+ useEffect22(() => {
18235
+ if (slug) warnSlugDeprecated();
18236
+ }, [slug]);
18224
18237
  useEffect22(() => {
18225
18238
  if (typeof window === "undefined") return;
18226
18239
  let accessToken = sessionStorage.getItem("access_token");
18227
18240
  let orgId = sessionStorage.getItem("pc_org_id");
18228
18241
  let workspaceId = sessionStorage.getItem("pc_workspace_id");
18229
- let orgSlug = sessionStorage.getItem("pc_org_slug");
18230
- if (authAccessToken && (!accessToken || !orgId || !workspaceId || !orgSlug)) {
18242
+ if (authAccessToken && (!accessToken || !orgId || !workspaceId)) {
18231
18243
  const decoded = decodeJwtToken(authAccessToken);
18232
18244
  if (decoded) {
18233
18245
  accessToken = accessToken || authAccessToken;
18234
18246
  orgId = orgId || (typeof decoded.organisation_uuid === "string" ? decoded.organisation_uuid : null);
18235
18247
  workspaceId = workspaceId || (typeof decoded.workspace_uuid === "string" ? decoded.workspace_uuid : null);
18236
- orgSlug = orgSlug || (typeof decoded.organisation_slug === "string" ? decoded.organisation_slug : null);
18237
18248
  if (accessToken) sessionStorage.setItem("access_token", accessToken);
18238
18249
  if (orgId) sessionStorage.setItem("pc_org_id", orgId);
18239
18250
  if (workspaceId) sessionStorage.setItem("pc_workspace_id", workspaceId);
18240
- if (orgSlug) sessionStorage.setItem("pc_org_slug", orgSlug);
18241
18251
  const contact = resolveContactFromJwt(decoded);
18242
18252
  if (contact) {
18243
18253
  sessionStorage.setItem("email", contact);
18244
18254
  }
18245
18255
  }
18246
18256
  }
18247
- const effectiveSlug = slug || orgSlug || "";
18248
- if (accessToken && orgId && workspaceId && effectiveSlug) {
18257
+ if (accessToken && orgId && workspaceId) {
18249
18258
  const decoded = decodeJwtToken(accessToken);
18250
18259
  const orgNameFromJwt = decoded == null ? void 0 : decoded.organisation_name;
18251
- const orgName = typeof orgNameFromJwt === "string" && orgNameFromJwt.trim() !== "" ? orgNameFromJwt : effectiveSlug.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
18260
+ const orgName = typeof orgNameFromJwt === "string" && orgNameFromJwt.trim() !== "" ? orgNameFromJwt : "";
18252
18261
  setOrganization({
18253
18262
  uuid: orgId,
18254
18263
  suid: "",
18255
18264
  name: orgName,
18256
- slug: effectiveSlug,
18265
+ slug: "",
18257
18266
  description: "",
18258
18267
  domain: "",
18259
18268
  workspaces: [{
@@ -18274,7 +18283,7 @@ function PrivacyCenterLayoutContent({
18274
18283
  setOrganization(null);
18275
18284
  setIsLoadingOrg(false);
18276
18285
  }
18277
- }, [slug, authAccessToken]);
18286
+ }, [authAccessToken]);
18278
18287
  useEffect22(() => {
18279
18288
  if (isLoadingOrg || !organization) {
18280
18289
  return;
@@ -18287,7 +18296,7 @@ function PrivacyCenterLayoutContent({
18287
18296
  authCheckInProgressRef.current = true;
18288
18297
  try {
18289
18298
  await checkAndRefreshAuth(
18290
- organization.slug || slug,
18299
+ "",
18291
18300
  organization == null ? void 0 : organization.uuid,
18292
18301
  (_a = organization == null ? void 0 : organization.workspaces[0]) == null ? void 0 : _a.uuid,
18293
18302
  consentClient
@@ -18301,7 +18310,7 @@ function PrivacyCenterLayoutContent({
18301
18310
  }
18302
18311
  };
18303
18312
  checkAuth();
18304
- }, [slug, organization, isLoadingOrg, consentClient, authAccessToken]);
18313
+ }, [organization, isLoadingOrg, consentClient, authAccessToken]);
18305
18314
  const showSignIn = builtInSignIn && !isLoadingOrg && !organization;
18306
18315
  const showPortal = Boolean(organization) && !isLoadingOrg && !isCheckingAuth;
18307
18316
  useEffect22(() => {
@@ -18315,7 +18324,7 @@ function PrivacyCenterLayoutContent({
18315
18324
  () => expireSession("timeout")
18316
18325
  );
18317
18326
  if (showSignIn) {
18318
- return /* @__PURE__ */ jsx53(PrivacyCenterSignIn, { slug });
18327
+ return /* @__PURE__ */ jsx53(PrivacyCenterSignIn, {});
18319
18328
  }
18320
18329
  if (isLoadingOrg || !organization || isCheckingAuth) {
18321
18330
  return /* @__PURE__ */ jsx53("div", { style: {
@@ -23056,7 +23065,6 @@ function Form({
23056
23065
  const queryClient = useQueryClient();
23057
23066
  const timePeriodOptions = useTimePeriodOptions();
23058
23067
  const { organization } = useOrganization();
23059
- const orgSlug = (organization == null ? void 0 : organization.slug) || (organization == null ? void 0 : organization.name) || "";
23060
23068
  const isCaseManagementContext = typeof window !== "undefined" && window.location.pathname.includes("/case-management");
23061
23069
  const [requestType, setRequestType] = useState30(null);
23062
23070
  const [timePeriod, setTimePeriod] = useState30("");
@@ -23647,7 +23655,7 @@ function Form({
23647
23655
  if (!organizationId || !workspaceId) {
23648
23656
  throw new Error("Organization ID and Workspace ID are required for file upload");
23649
23657
  }
23650
- const authToken = await ensureValidToken(organizationId, workspaceId, orgSlug, authContext, consentClient);
23658
+ const authToken = await ensureValidToken(organizationId, workspaceId, void 0, authContext, consentClient);
23651
23659
  if (!authToken) {
23652
23660
  throw new Error("Authentication token is required for file upload");
23653
23661
  }
@@ -27863,45 +27871,21 @@ function PrivacyCenterHomePage() {
27863
27871
  // src/RedactoPrivacyCenter/context/PrivacyCenterSettingsContext.tsx
27864
27872
  import { useEffect as useEffect39, useMemo as useMemo30, useState as useState39 } from "react";
27865
27873
 
27866
- // src/RedactoPrivacyCenter/api/organizationLookup.ts
27867
- var cache = /* @__PURE__ */ new Map();
27868
- var isOrganisation = (value) => typeof value === "object" && value !== null && typeof value.uuid === "string";
27869
- var fetchOrganisationBySlug = (slug, consentBaseUrl) => {
27870
- const url = `${userServiceBaseUrl(consentBaseUrl)}/organizations/exists?slug=${encodeURIComponent(slug)}`;
27871
- const cached = cache.get(url);
27872
- if (cached) {
27873
- return cached;
27874
- }
27875
- const request = apiFetch(url, { method: "GET" }).then((body) => {
27876
- if (isOrganisation(body)) {
27877
- return body;
27878
- }
27879
- cache.delete(url);
27880
- return null;
27881
- }).catch((error) => {
27882
- cache.delete(url);
27883
- console.warn("[RedactoPrivacyCenter] organisation lookup failed:", error);
27884
- return null;
27885
- });
27886
- cache.set(url, request);
27887
- return request;
27888
- };
27889
-
27890
27874
  // src/RedactoPrivacyCenter/settings/api.ts
27891
- var cache2 = /* @__PURE__ */ new Map();
27875
+ var cache = /* @__PURE__ */ new Map();
27892
27876
  var freshEntry = (url) => {
27893
- const entry = cache2.get(url);
27877
+ const entry = cache.get(url);
27894
27878
  if (!entry) {
27895
27879
  return null;
27896
27880
  }
27897
27881
  if (Date.now() >= entry.expiresAt) {
27898
- cache2.delete(url);
27882
+ cache.delete(url);
27899
27883
  return null;
27900
27884
  }
27901
27885
  return entry;
27902
27886
  };
27903
27887
  var trimTrailingSlash = (url) => url.replace(/\/+$/, "");
27904
- var privacyCenterSettingsUrl = (baseUrl, organisationUuid, language) => `${trimTrailingSlash(baseUrl)}/public/organisations/${encodeURIComponent(
27888
+ var privacyCenterSettingsUrl = (baseUrl, organisationUuid, language) => `${trimTrailingSlash(resolveEndpoints(baseUrl).baseUrl)}/public/organisations/${encodeURIComponent(
27905
27889
  organisationUuid
27906
27890
  )}/privacy-center-settings/?${SETTINGS_LANG_PARAM}=${encodeURIComponent(language)}`;
27907
27891
  var isSettingsResponse = (value) => typeof value === "object" && value !== null && "settings" in value && typeof value.settings === "object" && value.settings !== null;
@@ -27913,8 +27897,8 @@ var fetchPublicPrivacyCenterSettings = (baseUrl, organisationUuid, language) =>
27913
27897
  }
27914
27898
  const forget = () => {
27915
27899
  var _a;
27916
- if (((_a = cache2.get(url)) == null ? void 0 : _a.request) === request) {
27917
- cache2.delete(url);
27900
+ if (((_a = cache.get(url)) == null ? void 0 : _a.request) === request) {
27901
+ cache.delete(url);
27918
27902
  }
27919
27903
  };
27920
27904
  const request = apiFetch(url, {
@@ -27932,7 +27916,7 @@ var fetchPublicPrivacyCenterSettings = (baseUrl, organisationUuid, language) =>
27932
27916
  }
27933
27917
  return null;
27934
27918
  });
27935
- cache2.set(url, { request, expiresAt: Date.now() + SETTINGS_CACHE_TTL_MS });
27919
+ cache.set(url, { request, expiresAt: Date.now() + SETTINGS_CACHE_TTL_MS });
27936
27920
  return request;
27937
27921
  };
27938
27922
  var hasCachedPrivacyCenterSettings = (baseUrl, organisationUuid, language) => freshEntry(privacyCenterSettingsUrl(baseUrl, organisationUuid, language)) !== null;
@@ -27949,15 +27933,15 @@ var readSession = (key) => {
27949
27933
  var resolveOrganisationIds = ({
27950
27934
  organisationUuid,
27951
27935
  workspaceUuid,
27952
- accessToken,
27953
- slug
27936
+ accessToken
27954
27937
  }) => {
27955
27938
  var _a, _b, _c, _d;
27956
27939
  const claims = accessToken ? decodeJwtToken(accessToken) : null;
27957
- const storedSlug = readSession("pc_org_slug");
27958
- const sessionMatches = !slug || !storedSlug || storedSlug === slug;
27940
+ const storedOrganisation = readSession("pc_org_id");
27941
+ const organisation = (_b = (_a = clean(organisationUuid)) != null ? _a : clean(claims == null ? void 0 : claims.organisation_uuid)) != null ? _b : storedOrganisation;
27942
+ const sessionMatches = organisation !== null && organisation === storedOrganisation;
27959
27943
  return {
27960
- organisationUuid: (_b = (_a = clean(organisationUuid)) != null ? _a : clean(claims == null ? void 0 : claims.organisation_uuid)) != null ? _b : sessionMatches ? readSession("pc_org_id") : null,
27944
+ organisationUuid: organisation,
27961
27945
  workspaceUuid: (_d = (_c = clean(workspaceUuid)) != null ? _c : clean(claims == null ? void 0 : claims.workspace_uuid)) != null ? _d : sessionMatches ? readSession("pc_workspace_id") : null
27962
27946
  };
27963
27947
  };
@@ -28216,55 +28200,9 @@ var resolveBrandContact = (raw) => {
28216
28200
  // src/RedactoPrivacyCenter/context/PrivacyCenterSettingsContext.tsx
28217
28201
  import { jsx as jsx101 } from "react/jsx-runtime";
28218
28202
  var requestLanguageFor = (language) => LANGUAGE_CODES.includes(language) ? language : "en";
28219
- var useResolvedOrganisation = (baseUrl, slug, known, canLookUp) => {
28220
- const needsLookup = canLookUp && Boolean(slug) && (!known.organisationUuid || !known.workspaceUuid);
28221
- const lookupKey = `${baseUrl}|${slug}`;
28222
- const [lookup, setLookup] = useState39(null);
28223
- useEffect39(() => {
28224
- if (!needsLookup) {
28225
- return void 0;
28226
- }
28227
- let cancelled = false;
28228
- void fetchOrganisationBySlug(slug, baseUrl).then((organisation) => {
28229
- var _a, _b, _c;
28230
- if (cancelled) {
28231
- return;
28232
- }
28233
- setLookup({
28234
- key: lookupKey,
28235
- ids: organisation ? {
28236
- organisationUuid: organisation.uuid,
28237
- workspaceUuid: (_c = (_b = (_a = organisation.workspaces) == null ? void 0 : _a[0]) == null ? void 0 : _b.uuid) != null ? _c : null
28238
- } : null
28239
- });
28240
- });
28241
- return () => {
28242
- cancelled = true;
28243
- };
28244
- }, [needsLookup, slug, baseUrl, lookupKey]);
28245
- return useMemo30(() => {
28246
- var _a, _b, _c, _d;
28247
- if (!needsLookup) {
28248
- return { ...known, status: "resolved" };
28249
- }
28250
- if ((lookup == null ? void 0 : lookup.key) !== lookupKey) {
28251
- return { ...known, status: "resolving" };
28252
- }
28253
- const found = lookup.ids;
28254
- const sameOrganisation = !known.organisationUuid || known.organisationUuid === (found == null ? void 0 : found.organisationUuid);
28255
- const organisationUuid = (_b = (_a = known.organisationUuid) != null ? _a : found == null ? void 0 : found.organisationUuid) != null ? _b : null;
28256
- const workspaceUuid = (_d = known.workspaceUuid) != null ? _d : sameOrganisation ? (_c = found == null ? void 0 : found.workspaceUuid) != null ? _c : null : null;
28257
- return {
28258
- organisationUuid,
28259
- workspaceUuid,
28260
- status: organisationUuid && workspaceUuid ? "resolved" : "failed"
28261
- };
28262
- }, [needsLookup, known, lookup, lookupKey]);
28263
- };
28264
28203
  var PrivacyCenterSettingsProvider = ({
28265
28204
  children,
28266
28205
  baseUrl,
28267
- slug,
28268
28206
  accessToken,
28269
28207
  organisationUuid,
28270
28208
  workspaceUuid,
@@ -28272,11 +28210,13 @@ var PrivacyCenterSettingsProvider = ({
28272
28210
  builtInSignIn = false
28273
28211
  }) => {
28274
28212
  const { currentLanguage } = useCurrentLanguage();
28275
- const known = useMemo30(
28276
- () => resolveOrganisationIds({ organisationUuid, workspaceUuid, accessToken, slug }),
28277
- [organisationUuid, workspaceUuid, accessToken, slug]
28278
- );
28279
- const organisation = useResolvedOrganisation(baseUrl, slug, known, builtInSignIn);
28213
+ const organisation = useMemo30(() => {
28214
+ const known = resolveOrganisationIds({ organisationUuid, workspaceUuid, accessToken });
28215
+ return {
28216
+ ...known,
28217
+ status: known.organisationUuid && known.workspaceUuid ? "resolved" : "failed"
28218
+ };
28219
+ }, [organisationUuid, workspaceUuid, accessToken]);
28280
28220
  const orgUuid = organisation.organisationUuid;
28281
28221
  const requestLanguage = requestLanguageFor(currentLanguage);
28282
28222
  const [remote, setRemote] = useState39(null);
@@ -28321,8 +28261,8 @@ var PrivacyCenterSettingsProvider = ({
28321
28261
  const isCustomised = isPublished || hasHostOverrides(overrides);
28322
28262
  useLanguagePolicy(settings, isCustomised);
28323
28263
  const value = useMemo30(
28324
- () => ({ settings, status, isCustomised, organisation, slug, builtInSignIn, brandContact }),
28325
- [settings, status, isCustomised, organisation, slug, builtInSignIn, brandContact]
28264
+ () => ({ settings, status, isCustomised, organisation, builtInSignIn, brandContact }),
28265
+ [settings, status, isCustomised, organisation, builtInSignIn, brandContact]
28326
28266
  );
28327
28267
  return /* @__PURE__ */ jsx101(PrivacyCenterSettingsContext.Provider, { value, children });
28328
28268
  };
@@ -31519,7 +31459,7 @@ function SettingsAppearance({ children }) {
31519
31459
  function RedactoPrivacyCenter({
31520
31460
  baseUrl,
31521
31461
  ledgerBaseUrl,
31522
- slug,
31462
+ slug = "",
31523
31463
  accessToken,
31524
31464
  refreshToken,
31525
31465
  token,
@@ -31546,13 +31486,12 @@ function RedactoPrivacyCenter({
31546
31486
  PrivacyCenterSettingsProvider,
31547
31487
  {
31548
31488
  baseUrl,
31549
- slug,
31550
31489
  accessToken,
31551
31490
  organisationUuid,
31552
31491
  workspaceUuid,
31553
31492
  overrides: settings,
31554
31493
  builtInSignIn: builtInSignIn && !token,
31555
- children: /* @__PURE__ */ jsx103(PrivacyCenterRoot, { children: /* @__PURE__ */ jsx103(SettingsAppearance, { children: /* @__PURE__ */ jsx103(BrandingProvider, { slug, baseUrl, children: /* @__PURE__ */ jsx103(BaseUrlProvider, { baseUrl, ledgerBaseUrl, children: /* @__PURE__ */ jsx103(
31494
+ children: /* @__PURE__ */ jsx103(PrivacyCenterRoot, { children: /* @__PURE__ */ jsx103(SettingsAppearance, { children: /* @__PURE__ */ jsx103(BrandingProvider, { baseUrl, children: /* @__PURE__ */ jsx103(BaseUrlProvider, { baseUrl, ledgerBaseUrl, children: /* @__PURE__ */ jsx103(
31556
31495
  AuthProvider,
31557
31496
  {
31558
31497
  accessToken,
@@ -31563,7 +31502,6 @@ function RedactoPrivacyCenter({
31563
31502
  sandboxMobile: mobile,
31564
31503
  organisationUuid,
31565
31504
  workspaceUuid,
31566
- slug,
31567
31505
  onError,
31568
31506
  children: /* @__PURE__ */ jsx103(NavigationProvider, { initialPage, children: /* @__PURE__ */ jsx103(PageChromeProvider, { children: /* @__PURE__ */ jsx103(PrivacyCenterLayout, { slug, onBack, children: /* @__PURE__ */ jsx103(PrivacyCenterHomePage, {}) }) }) })
31569
31507
  }