@redacto.io/consent-sdk-react 7.2.0 → 7.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @redacto.io/consent-sdk-react
2
2
 
3
+ ## 7.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - change branding path
8
+
3
9
  ## 7.2.0
4
10
 
5
11
  ### Minor Changes
@@ -11947,9 +11947,11 @@ var CASE_DETAILS_PREFIX = "/case-details/";
11947
11947
  var import_react13 = require("react");
11948
11948
 
11949
11949
  // src/RedactoPrivacyCenter/api/orgBranding.ts
11950
- var USER_SERVER_BASE_URL = "https://api.redacto.tech/user/api/0";
11951
- async function fetchOrgBranding(slug) {
11952
- const url = `${USER_SERVER_BASE_URL}/public/org-branding/by-slug/${encodeURIComponent(slug)}`;
11950
+ function getUserServerBaseUrl(baseUrl) {
11951
+ return baseUrl.includes(".io") ? "https://api.redacto.io/user/api/0" : "https://api.redacto.tech/user/api/0";
11952
+ }
11953
+ async function fetchOrgBranding(slug, baseUrl) {
11954
+ const url = `${getUserServerBaseUrl(baseUrl)}/public/org-branding/by-slug/${encodeURIComponent(slug)}`;
11953
11955
  return apiFetch(url, { method: "GET" });
11954
11956
  }
11955
11957
 
@@ -12012,12 +12014,16 @@ function clearBrandingTheme() {
12012
12014
  // src/RedactoPrivacyCenter/context/BrandingContext.tsx
12013
12015
  var import_jsx_runtime27 = require("react/jsx-runtime");
12014
12016
  var BrandingContext = (0, import_react13.createContext)(null);
12015
- var BrandingProvider = ({ children, slug }) => {
12017
+ var BrandingProvider = ({
12018
+ children,
12019
+ slug,
12020
+ baseUrl
12021
+ }) => {
12016
12022
  const [branding, setBranding] = (0, import_react13.useState)(null);
12017
12023
  (0, import_react13.useEffect)(() => {
12018
12024
  if (!slug) return;
12019
12025
  let cancelled = false;
12020
- fetchOrgBranding(slug).then((data) => {
12026
+ fetchOrgBranding(slug, baseUrl).then((data) => {
12021
12027
  if (!cancelled) setBranding(data);
12022
12028
  }).catch((error) => {
12023
12029
  console.warn("[RedactoPrivacyCenter] org branding fetch failed:", error);
@@ -12025,7 +12031,7 @@ var BrandingProvider = ({ children, slug }) => {
12025
12031
  return () => {
12026
12032
  cancelled = true;
12027
12033
  };
12028
- }, [slug]);
12034
+ }, [slug, baseUrl]);
12029
12035
  (0, import_react13.useEffect)(() => {
12030
12036
  if (!branding) return;
12031
12037
  applyBrandingTheme(branding.theme);
@@ -24308,7 +24314,7 @@ function RedactoPrivacyCenter({
24308
24314
  initialPage = "consent-manager",
24309
24315
  onBack
24310
24316
  }) {
24311
- return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_react_i18next44.I18nextProvider, { i18n: i18n_default, children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(BrandingProvider, { slug, children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(BaseUrlProvider, { baseUrl, children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
24317
+ return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_react_i18next44.I18nextProvider, { i18n: i18n_default, children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(BrandingProvider, { slug, baseUrl, children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(BaseUrlProvider, { baseUrl, children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
24312
24318
  AuthProvider,
24313
24319
  {
24314
24320
  accessToken,
@@ -11885,9 +11885,11 @@ var CASE_DETAILS_PREFIX = "/case-details/";
11885
11885
  import { createContext as createContext6, useContext as useContext5, useEffect as useEffect7, useState as useState8 } from "react";
11886
11886
 
11887
11887
  // src/RedactoPrivacyCenter/api/orgBranding.ts
11888
- var USER_SERVER_BASE_URL = "https://api.redacto.tech/user/api/0";
11889
- async function fetchOrgBranding(slug) {
11890
- const url = `${USER_SERVER_BASE_URL}/public/org-branding/by-slug/${encodeURIComponent(slug)}`;
11888
+ function getUserServerBaseUrl(baseUrl) {
11889
+ return baseUrl.includes(".io") ? "https://api.redacto.io/user/api/0" : "https://api.redacto.tech/user/api/0";
11890
+ }
11891
+ async function fetchOrgBranding(slug, baseUrl) {
11892
+ const url = `${getUserServerBaseUrl(baseUrl)}/public/org-branding/by-slug/${encodeURIComponent(slug)}`;
11891
11893
  return apiFetch(url, { method: "GET" });
11892
11894
  }
11893
11895
 
@@ -11950,12 +11952,16 @@ function clearBrandingTheme() {
11950
11952
  // src/RedactoPrivacyCenter/context/BrandingContext.tsx
11951
11953
  import { jsx as jsx27 } from "react/jsx-runtime";
11952
11954
  var BrandingContext = createContext6(null);
11953
- var BrandingProvider = ({ children, slug }) => {
11955
+ var BrandingProvider = ({
11956
+ children,
11957
+ slug,
11958
+ baseUrl
11959
+ }) => {
11954
11960
  const [branding, setBranding] = useState8(null);
11955
11961
  useEffect7(() => {
11956
11962
  if (!slug) return;
11957
11963
  let cancelled = false;
11958
- fetchOrgBranding(slug).then((data) => {
11964
+ fetchOrgBranding(slug, baseUrl).then((data) => {
11959
11965
  if (!cancelled) setBranding(data);
11960
11966
  }).catch((error) => {
11961
11967
  console.warn("[RedactoPrivacyCenter] org branding fetch failed:", error);
@@ -11963,7 +11969,7 @@ var BrandingProvider = ({ children, slug }) => {
11963
11969
  return () => {
11964
11970
  cancelled = true;
11965
11971
  };
11966
- }, [slug]);
11972
+ }, [slug, baseUrl]);
11967
11973
  useEffect7(() => {
11968
11974
  if (!branding) return;
11969
11975
  applyBrandingTheme(branding.theme);
@@ -24270,7 +24276,7 @@ function RedactoPrivacyCenter({
24270
24276
  initialPage = "consent-manager",
24271
24277
  onBack
24272
24278
  }) {
24273
- return /* @__PURE__ */ jsx80(I18nextProvider, { i18n: i18n_default, children: /* @__PURE__ */ jsx80(BrandingProvider, { slug, children: /* @__PURE__ */ jsx80(BaseUrlProvider, { baseUrl, children: /* @__PURE__ */ jsx80(
24279
+ return /* @__PURE__ */ jsx80(I18nextProvider, { i18n: i18n_default, children: /* @__PURE__ */ jsx80(BrandingProvider, { slug, baseUrl, children: /* @__PURE__ */ jsx80(BaseUrlProvider, { baseUrl, children: /* @__PURE__ */ jsx80(
24274
24280
  AuthProvider,
24275
24281
  {
24276
24282
  accessToken,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redacto.io/consent-sdk-react",
3
- "version": "7.2.0",
3
+ "version": "7.3.0",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -34,7 +34,7 @@ export function RedactoPrivacyCenter({
34
34
  }: RedactoPrivacyCenterProps) {
35
35
  return (
36
36
  <I18nextProvider i18n={i18n}>
37
- <BrandingProvider slug={slug}>
37
+ <BrandingProvider slug={slug} baseUrl={baseUrl}>
38
38
  <BaseUrlProvider baseUrl={baseUrl}>
39
39
  <AuthProvider
40
40
  accessToken={accessToken}
@@ -1,9 +1,16 @@
1
1
  import { apiFetch } from './fetcher';
2
2
  import type { OrgBrandingDetail } from '../lib/types';
3
3
 
4
- const USER_SERVER_BASE_URL = 'https://api.redacto.tech/user/api/0';
4
+ function getUserServerBaseUrl(baseUrl: string): string {
5
+ return baseUrl.includes('.io')
6
+ ? 'https://api.redacto.io/user/api/0'
7
+ : 'https://api.redacto.tech/user/api/0';
8
+ }
5
9
 
6
- export async function fetchOrgBranding(slug: string): Promise<OrgBrandingDetail> {
7
- const url = `${USER_SERVER_BASE_URL}/public/org-branding/by-slug/${encodeURIComponent(slug)}`;
10
+ export async function fetchOrgBranding(
11
+ slug: string,
12
+ baseUrl: string,
13
+ ): Promise<OrgBrandingDetail> {
14
+ const url = `${getUserServerBaseUrl(baseUrl)}/public/org-branding/by-slug/${encodeURIComponent(slug)}`;
8
15
  return apiFetch<OrgBrandingDetail>(url, { method: 'GET' });
9
16
  }
@@ -7,13 +7,21 @@ type BrandingContextValue = { branding: OrgBrandingDetail | null };
7
7
 
8
8
  const BrandingContext = createContext<BrandingContextValue | null>(null);
9
9
 
10
- export const BrandingProvider = ({ children, slug }: { children: ReactNode; slug: string }) => {
10
+ export const BrandingProvider = ({
11
+ children,
12
+ slug,
13
+ baseUrl,
14
+ }: {
15
+ children: ReactNode;
16
+ slug: string;
17
+ baseUrl: string;
18
+ }) => {
11
19
  const [branding, setBranding] = useState<OrgBrandingDetail | null>(null);
12
20
 
13
21
  useEffect(() => {
14
22
  if (!slug) return;
15
23
  let cancelled = false;
16
- fetchOrgBranding(slug)
24
+ fetchOrgBranding(slug, baseUrl)
17
25
  .then((data) => {
18
26
  if (!cancelled) setBranding(data);
19
27
  })
@@ -23,7 +31,7 @@ export const BrandingProvider = ({ children, slug }: { children: ReactNode; slug
23
31
  return () => {
24
32
  cancelled = true;
25
33
  };
26
- }, [slug]);
34
+ }, [slug, baseUrl]);
27
35
 
28
36
  useEffect(() => {
29
37
  if (!branding) return;