@redacto.io/consent-sdk-react 10.3.0-beta.6 → 10.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.
@@ -581,9 +581,15 @@ var useMediaQuery = (query) => {
581
581
  // src/shared/sandbox.ts
582
582
  var SANDBOX_TOKEN_HEADER = "X-Consent-Token";
583
583
 
584
+ // src/constants.ts
585
+ var DEFAULT_CONSENT_API_BASE_URL = "https://api.redacto.io/consent";
586
+ var USER_SERVICE_PATH = "/user/api/0";
587
+
584
588
  export {
585
589
  SANDBOX_TOKEN_HEADER,
586
590
  withIdempotencyKey,
591
+ DEFAULT_CONSENT_API_BASE_URL,
592
+ USER_SERVICE_PATH,
587
593
  DEFAULT_TEXT_SCALE,
588
594
  NOTICE_TEXT_SCALE_FACTORS,
589
595
  NOTICE_THEME_VARS,
package/dist/index.js CHANGED
@@ -278,6 +278,9 @@ ${body}`;
278
278
  }
279
279
  };
280
280
 
281
+ // src/constants.ts
282
+ var DEFAULT_CONSENT_API_BASE_URL = "https://api.redacto.io/consent";
283
+
281
284
  // src/shared/notice-consent-status.ts
282
285
  var import_jwt_decode = require("jwt-decode");
283
286
  var decodeNoticeConsentToken = (token) => {
@@ -356,7 +359,7 @@ var fetchNoticeConsentStatus = async ({
356
359
  var isNoticeFullyConsented = (status) => status.consented && status.all_mandatory_active;
357
360
 
358
361
  // src/RedactoNoticeConsent/api/index.ts
359
- var BASE_URL = "https://api.redacto.io/consent";
362
+ var BASE_URL = DEFAULT_CONSENT_API_BASE_URL;
360
363
  var apiCache = /* @__PURE__ */ new Map();
361
364
  var CACHE_TTL = 5 * 60 * 1e3;
362
365
  function getCachedData(key) {
@@ -9801,7 +9804,7 @@ var RedactoNoticeConsent = (props) => /* @__PURE__ */ (0, import_jsx_runtime7.js
9801
9804
  var import_react10 = require("react");
9802
9805
 
9803
9806
  // src/RedactoNoticeConsentInline/api/index.ts
9804
- var BASE_URL2 = "https://api.redacto.tech/consent";
9807
+ var BASE_URL2 = DEFAULT_CONSENT_API_BASE_URL;
9805
9808
  var fetchConsentContent2 = async ({
9806
9809
  org_uuid,
9807
9810
  workspace_uuid,
@@ -12059,7 +12062,7 @@ var DPO_AUDIO_ELEMENT_MAP2 = [
12059
12062
  ];
12060
12063
 
12061
12064
  // src/RedactoNoticeAssisted/api/index.ts
12062
- var BASE_URL3 = "https://api.redacto.io/consent";
12065
+ var BASE_URL3 = DEFAULT_CONSENT_API_BASE_URL;
12063
12066
  var publicScope = (baseUrl, organisationUuid, workspaceUuid) => `${baseUrl || BASE_URL3}/public/organisations/${organisationUuid}/workspaces/${workspaceUuid}`;
12064
12067
  var fetchAssistedNotice = async ({
12065
12068
  organisationUuid,
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  APPEARANCE_ATTRIBUTE,
3
3
  Collapse,
4
+ DEFAULT_CONSENT_API_BASE_URL,
4
5
  DEFAULT_TEXT_SCALE,
5
6
  GLASS_BLUR,
6
7
  GLASS_DEFAULT_TINT,
@@ -30,7 +31,7 @@ import {
30
31
  withAlpha,
31
32
  withColorScheme,
32
33
  withIdempotencyKey
33
- } from "./chunk-EYHKLIAJ.mjs";
34
+ } from "./chunk-SZWLAJB7.mjs";
34
35
  import {
35
36
  FONT_FAMILY_SEPARATOR,
36
37
  FONT_NAME_QUOTE_CHARACTERS,
@@ -259,7 +260,7 @@ var fetchNoticeConsentStatus = async ({
259
260
  var isNoticeFullyConsented = (status) => status.consented && status.all_mandatory_active;
260
261
 
261
262
  // src/RedactoNoticeConsent/api/index.ts
262
- var BASE_URL = "https://api.redacto.io/consent";
263
+ var BASE_URL = DEFAULT_CONSENT_API_BASE_URL;
263
264
  var apiCache = /* @__PURE__ */ new Map();
264
265
  var CACHE_TTL = 5 * 60 * 1e3;
265
266
  function getCachedData(key) {
@@ -9006,7 +9007,7 @@ var RedactoNoticeConsent = (props) => /* @__PURE__ */ jsx6(NoticeConsentView, {
9006
9007
  import { useEffect as useEffect7, useMemo as useMemo4, useState as useState3, useRef as useRef4, useCallback as useCallback4, memo } from "react";
9007
9008
 
9008
9009
  // src/RedactoNoticeConsentInline/api/index.ts
9009
- var BASE_URL2 = "https://api.redacto.tech/consent";
9010
+ var BASE_URL2 = DEFAULT_CONSENT_API_BASE_URL;
9010
9011
  var fetchConsentContent2 = async ({
9011
9012
  org_uuid,
9012
9013
  workspace_uuid,
@@ -11264,7 +11265,7 @@ var DPO_AUDIO_ELEMENT_MAP2 = [
11264
11265
  ];
11265
11266
 
11266
11267
  // src/RedactoNoticeAssisted/api/index.ts
11267
- var BASE_URL3 = "https://api.redacto.io/consent";
11268
+ var BASE_URL3 = DEFAULT_CONSENT_API_BASE_URL;
11268
11269
  var publicScope = (baseUrl, organisationUuid, workspaceUuid) => `${baseUrl || BASE_URL3}/public/organisations/${organisationUuid}/workspaces/${workspaceUuid}`;
11269
11270
  var fetchAssistedNotice = async ({
11270
11271
  organisationUuid,
@@ -14051,12 +14051,22 @@ var poweredByRedacto_default = 'data:image/svg+xml,<svg width="81" height="27" v
14051
14051
  // src/RedactoPrivacyCenter/context/BrandingContext.tsx
14052
14052
  var import_react20 = require("react");
14053
14053
 
14054
+ // src/constants.ts
14055
+ var DEFAULT_CONSENT_API_BASE_URL = "https://api.redacto.io/consent";
14056
+ var USER_SERVICE_PATH = "/user/api/0";
14057
+
14054
14058
  // src/RedactoPrivacyCenter/api/orgBranding.ts
14055
- function getUserServerBaseUrl(baseUrl) {
14056
- return baseUrl.includes(".io") ? "https://api.redacto.io/user/api/0" : "https://api.redacto.tech/user/api/0";
14059
+ var ORIGIN = /^https?:\/\/(?:\[[0-9a-f:.]+\]|[^\s/?#@:[\]]+)(?::\d+)?(?=[/?#]|$)/i;
14060
+ function originOf(url) {
14061
+ const match = ORIGIN.exec(url.trim());
14062
+ return match ? match[0] : "";
14063
+ }
14064
+ function userServiceBaseUrl(consentBaseUrl) {
14065
+ const origin = originOf(consentBaseUrl) || originOf(DEFAULT_CONSENT_API_BASE_URL);
14066
+ return origin + USER_SERVICE_PATH;
14057
14067
  }
14058
14068
  async function fetchOrgBranding(slug, baseUrl) {
14059
- const url = `${getUserServerBaseUrl(baseUrl)}/public/org-branding/by-slug/${encodeURIComponent(slug)}`;
14069
+ const url = `${userServiceBaseUrl(baseUrl)}/public/org-branding/by-slug/${encodeURIComponent(slug)}`;
14060
14070
  return apiFetch(url, { method: "GET" });
14061
14071
  }
14062
14072
 
@@ -2,18 +2,20 @@ import {
2
2
  APPEARANCE_ATTRIBUTE,
3
3
  Collapse,
4
4
  DEFAULT_APPEARANCE,
5
+ DEFAULT_CONSENT_API_BASE_URL,
5
6
  GLASS_BLUR,
6
7
  GLASS_RADIUS,
7
8
  MOTION,
8
9
  NOTICE_ROOT_ATTRIBUTE,
9
10
  SANDBOX_TOKEN_HEADER,
11
+ USER_SERVICE_PATH,
10
12
  getAppearanceLayout,
11
13
  glassPalette,
12
14
  resolveAppearance,
13
15
  useIsomorphicLayoutEffect,
14
16
  useMediaQuery,
15
17
  withIdempotencyKey
16
- } from "./chunk-EYHKLIAJ.mjs";
18
+ } from "./chunk-SZWLAJB7.mjs";
17
19
 
18
20
  // src/RedactoPrivacyCenter/RedactoPrivacyCenter.tsx
19
21
  import { I18nextProvider } from "react-i18next";
@@ -13761,11 +13763,17 @@ var poweredByRedacto_default = 'data:image/svg+xml,<svg width="81" height="27" v
13761
13763
  import { createContext as createContext8, useContext as useContext6, useEffect as useEffect11, useState as useState11 } from "react";
13762
13764
 
13763
13765
  // src/RedactoPrivacyCenter/api/orgBranding.ts
13764
- function getUserServerBaseUrl(baseUrl) {
13765
- return baseUrl.includes(".io") ? "https://api.redacto.io/user/api/0" : "https://api.redacto.tech/user/api/0";
13766
+ var ORIGIN = /^https?:\/\/(?:\[[0-9a-f:.]+\]|[^\s/?#@:[\]]+)(?::\d+)?(?=[/?#]|$)/i;
13767
+ function originOf(url) {
13768
+ const match = ORIGIN.exec(url.trim());
13769
+ return match ? match[0] : "";
13770
+ }
13771
+ function userServiceBaseUrl(consentBaseUrl) {
13772
+ const origin = originOf(consentBaseUrl) || originOf(DEFAULT_CONSENT_API_BASE_URL);
13773
+ return origin + USER_SERVICE_PATH;
13766
13774
  }
13767
13775
  async function fetchOrgBranding(slug, baseUrl) {
13768
- const url = `${getUserServerBaseUrl(baseUrl)}/public/org-branding/by-slug/${encodeURIComponent(slug)}`;
13776
+ const url = `${userServiceBaseUrl(baseUrl)}/public/org-branding/by-slug/${encodeURIComponent(slug)}`;
13769
13777
  return apiFetch(url, { method: "GET" });
13770
13778
  }
13771
13779
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redacto.io/consent-sdk-react",
3
- "version": "10.3.0-beta.6",
3
+ "version": "10.3.0",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",