@redacto.io/consent-sdk-react 10.2.2-beta.3 → 10.3.0-beta.4
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/README.md +142 -56
- package/dist/chunk-EYHKLIAJ.mjs +618 -0
- package/dist/index.d.mts +349 -63
- package/dist/index.d.ts +349 -63
- package/dist/index.js +4727 -2136
- package/dist/index.mjs +4153 -2032
- package/dist/privacy-center.d.mts +49 -32
- package/dist/privacy-center.d.ts +49 -32
- package/dist/privacy-center.js +2659 -1535
- package/dist/privacy-center.mjs +2007 -1137
- package/dist/types-Bwtzvz4W.d.mts +66 -0
- package/dist/types-Bwtzvz4W.d.ts +66 -0
- package/package.json +1 -1
- package/dist/chunk-6EET4YOY.mjs +0 -93
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every colour the console can set on a notice, in the order the server's
|
|
3
|
+
* `NoticeAppearanceColorsIn` declares them. Keys outside this list are ignored,
|
|
4
|
+
* so a newer console never breaks an older SDK.
|
|
5
|
+
*/
|
|
6
|
+
declare const NOTICE_COLOR_KEYS: readonly ["background", "surface", "heading", "text", "muted_text", "link", "border", "overlay", "accept_all_bg", "accept_all_text", "accept_bg", "accept_text", "decline_bg", "decline_text", "decline_border", "language_bg", "language_text", "language_selected_bg", "language_selected_text", "toggle_on", "toggle_off", "toggle_knob", "tts_highlight_bg", "tts_highlight_text"];
|
|
7
|
+
/** How checkbox rows are drawn: native checkboxes, or switches. */
|
|
8
|
+
declare const NOTICE_CONTROL_STYLES: readonly ["checkbox", "switch"];
|
|
9
|
+
/** Phones: a centred modal, or a sheet docked to the bottom edge. */
|
|
10
|
+
declare const NOTICE_MOBILE_LAYOUTS: readonly ["modal", "sheet"];
|
|
11
|
+
/** Where the notice sits on wider screens. */
|
|
12
|
+
declare const NOTICE_DESKTOP_POSITIONS: readonly ["center", "bottom-right", "bottom-left", "bottom-bar"];
|
|
13
|
+
/** The page behind the notice: dimmed with `colors.overlay`, or left as is. */
|
|
14
|
+
declare const NOTICE_BACKDROPS: readonly ["dim", "none"];
|
|
15
|
+
/** Phone footer: three stacked buttons, or Accept All over the other two. */
|
|
16
|
+
declare const NOTICE_PHONE_FOOTERS: readonly ["stacked", "paired"];
|
|
17
|
+
declare const NOTICE_TEXT_SCALES: readonly ["sm", "md", "lg"];
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Surface and layout family a notice is drawn with, chosen in the Redacto
|
|
21
|
+
* console and served on `active_config.appearance.style`. Colours never come
|
|
22
|
+
* from the style: they come from the admin's palette, else the notice's brand.
|
|
23
|
+
*/
|
|
24
|
+
type AppearanceStyle = "classic" | "glass" | "minimal" | "soft";
|
|
25
|
+
/** The subset the Privacy Center's `settings.theme` accepts. */
|
|
26
|
+
type PrivacyCenterTheme = Extract<AppearanceStyle, "classic" | "glass">;
|
|
27
|
+
/** Every colour the console can set, keyed as the server serves them. */
|
|
28
|
+
type NoticeColorKey = (typeof NOTICE_COLOR_KEYS)[number];
|
|
29
|
+
type NoticeAppearanceColors = Partial<Record<NoticeColorKey, string>>;
|
|
30
|
+
type NoticeControlStyle = (typeof NOTICE_CONTROL_STYLES)[number];
|
|
31
|
+
type NoticeMobileLayout = (typeof NOTICE_MOBILE_LAYOUTS)[number];
|
|
32
|
+
type NoticeDesktopPosition = (typeof NOTICE_DESKTOP_POSITIONS)[number];
|
|
33
|
+
type NoticeBackdrop = (typeof NOTICE_BACKDROPS)[number];
|
|
34
|
+
type NoticePhoneFooter = (typeof NOTICE_PHONE_FOOTERS)[number];
|
|
35
|
+
type NoticeTextScale = (typeof NOTICE_TEXT_SCALES)[number];
|
|
36
|
+
/**
|
|
37
|
+
* `active_config.appearance` as served. Every key is optional and may be
|
|
38
|
+
* unknown to this SDK version, so it is read through `resolveNoticeAppearance`
|
|
39
|
+
* and never trusted directly; an empty object is classic.
|
|
40
|
+
*/
|
|
41
|
+
type NoticeAppearance = Readonly<{
|
|
42
|
+
version?: number;
|
|
43
|
+
style?: string;
|
|
44
|
+
template?: string | null;
|
|
45
|
+
color_mode?: string;
|
|
46
|
+
brand_color?: string | null;
|
|
47
|
+
colors?: NoticeAppearanceColors;
|
|
48
|
+
border_radius?: number;
|
|
49
|
+
selection_control?: string;
|
|
50
|
+
control_style?: string;
|
|
51
|
+
confirm_before_submit?: boolean;
|
|
52
|
+
mobile_layout?: string;
|
|
53
|
+
desktop_position?: string;
|
|
54
|
+
backdrop?: string;
|
|
55
|
+
collapsible_sections?: boolean;
|
|
56
|
+
phone_footer?: string;
|
|
57
|
+
auto_dark?: boolean;
|
|
58
|
+
dark_colors?: NoticeAppearanceColors;
|
|
59
|
+
max_width?: number;
|
|
60
|
+
logo_size?: number;
|
|
61
|
+
text_scale?: string;
|
|
62
|
+
motion?: boolean;
|
|
63
|
+
custom_css?: string;
|
|
64
|
+
}>;
|
|
65
|
+
|
|
66
|
+
export type { AppearanceStyle as A, NoticeControlStyle as N, PrivacyCenterTheme as P, NoticeMobileLayout as a, NoticeDesktopPosition as b, NoticeBackdrop as c, NoticePhoneFooter as d, NoticeTextScale as e, NoticeAppearance as f };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every colour the console can set on a notice, in the order the server's
|
|
3
|
+
* `NoticeAppearanceColorsIn` declares them. Keys outside this list are ignored,
|
|
4
|
+
* so a newer console never breaks an older SDK.
|
|
5
|
+
*/
|
|
6
|
+
declare const NOTICE_COLOR_KEYS: readonly ["background", "surface", "heading", "text", "muted_text", "link", "border", "overlay", "accept_all_bg", "accept_all_text", "accept_bg", "accept_text", "decline_bg", "decline_text", "decline_border", "language_bg", "language_text", "language_selected_bg", "language_selected_text", "toggle_on", "toggle_off", "toggle_knob", "tts_highlight_bg", "tts_highlight_text"];
|
|
7
|
+
/** How checkbox rows are drawn: native checkboxes, or switches. */
|
|
8
|
+
declare const NOTICE_CONTROL_STYLES: readonly ["checkbox", "switch"];
|
|
9
|
+
/** Phones: a centred modal, or a sheet docked to the bottom edge. */
|
|
10
|
+
declare const NOTICE_MOBILE_LAYOUTS: readonly ["modal", "sheet"];
|
|
11
|
+
/** Where the notice sits on wider screens. */
|
|
12
|
+
declare const NOTICE_DESKTOP_POSITIONS: readonly ["center", "bottom-right", "bottom-left", "bottom-bar"];
|
|
13
|
+
/** The page behind the notice: dimmed with `colors.overlay`, or left as is. */
|
|
14
|
+
declare const NOTICE_BACKDROPS: readonly ["dim", "none"];
|
|
15
|
+
/** Phone footer: three stacked buttons, or Accept All over the other two. */
|
|
16
|
+
declare const NOTICE_PHONE_FOOTERS: readonly ["stacked", "paired"];
|
|
17
|
+
declare const NOTICE_TEXT_SCALES: readonly ["sm", "md", "lg"];
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Surface and layout family a notice is drawn with, chosen in the Redacto
|
|
21
|
+
* console and served on `active_config.appearance.style`. Colours never come
|
|
22
|
+
* from the style: they come from the admin's palette, else the notice's brand.
|
|
23
|
+
*/
|
|
24
|
+
type AppearanceStyle = "classic" | "glass" | "minimal" | "soft";
|
|
25
|
+
/** The subset the Privacy Center's `settings.theme` accepts. */
|
|
26
|
+
type PrivacyCenterTheme = Extract<AppearanceStyle, "classic" | "glass">;
|
|
27
|
+
/** Every colour the console can set, keyed as the server serves them. */
|
|
28
|
+
type NoticeColorKey = (typeof NOTICE_COLOR_KEYS)[number];
|
|
29
|
+
type NoticeAppearanceColors = Partial<Record<NoticeColorKey, string>>;
|
|
30
|
+
type NoticeControlStyle = (typeof NOTICE_CONTROL_STYLES)[number];
|
|
31
|
+
type NoticeMobileLayout = (typeof NOTICE_MOBILE_LAYOUTS)[number];
|
|
32
|
+
type NoticeDesktopPosition = (typeof NOTICE_DESKTOP_POSITIONS)[number];
|
|
33
|
+
type NoticeBackdrop = (typeof NOTICE_BACKDROPS)[number];
|
|
34
|
+
type NoticePhoneFooter = (typeof NOTICE_PHONE_FOOTERS)[number];
|
|
35
|
+
type NoticeTextScale = (typeof NOTICE_TEXT_SCALES)[number];
|
|
36
|
+
/**
|
|
37
|
+
* `active_config.appearance` as served. Every key is optional and may be
|
|
38
|
+
* unknown to this SDK version, so it is read through `resolveNoticeAppearance`
|
|
39
|
+
* and never trusted directly; an empty object is classic.
|
|
40
|
+
*/
|
|
41
|
+
type NoticeAppearance = Readonly<{
|
|
42
|
+
version?: number;
|
|
43
|
+
style?: string;
|
|
44
|
+
template?: string | null;
|
|
45
|
+
color_mode?: string;
|
|
46
|
+
brand_color?: string | null;
|
|
47
|
+
colors?: NoticeAppearanceColors;
|
|
48
|
+
border_radius?: number;
|
|
49
|
+
selection_control?: string;
|
|
50
|
+
control_style?: string;
|
|
51
|
+
confirm_before_submit?: boolean;
|
|
52
|
+
mobile_layout?: string;
|
|
53
|
+
desktop_position?: string;
|
|
54
|
+
backdrop?: string;
|
|
55
|
+
collapsible_sections?: boolean;
|
|
56
|
+
phone_footer?: string;
|
|
57
|
+
auto_dark?: boolean;
|
|
58
|
+
dark_colors?: NoticeAppearanceColors;
|
|
59
|
+
max_width?: number;
|
|
60
|
+
logo_size?: number;
|
|
61
|
+
text_scale?: string;
|
|
62
|
+
motion?: boolean;
|
|
63
|
+
custom_css?: string;
|
|
64
|
+
}>;
|
|
65
|
+
|
|
66
|
+
export type { AppearanceStyle as A, NoticeControlStyle as N, PrivacyCenterTheme as P, NoticeMobileLayout as a, NoticeDesktopPosition as b, NoticeBackdrop as c, NoticePhoneFooter as d, NoticeTextScale as e, NoticeAppearance as f };
|
package/package.json
CHANGED
package/dist/chunk-6EET4YOY.mjs
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
// src/shared/idempotency.ts
|
|
2
|
-
var HEADER = "Idempotency-Key";
|
|
3
|
-
var pending = /* @__PURE__ */ new Map();
|
|
4
|
-
var MAX_PENDING = 16;
|
|
5
|
-
var mintKey = () => {
|
|
6
|
-
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
7
|
-
return crypto.randomUUID();
|
|
8
|
-
}
|
|
9
|
-
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 14)}-${Math.random().toString(36).slice(2, 14)}`;
|
|
10
|
-
};
|
|
11
|
-
var statusOf = (outcome) => {
|
|
12
|
-
if (typeof Response !== "undefined" && outcome instanceof Response) {
|
|
13
|
-
return outcome.status;
|
|
14
|
-
}
|
|
15
|
-
if (outcome && typeof outcome === "object" && "status" in outcome) {
|
|
16
|
-
const status = outcome.status;
|
|
17
|
-
if (typeof status === "number") return status;
|
|
18
|
-
}
|
|
19
|
-
return void 0;
|
|
20
|
-
};
|
|
21
|
-
var settledOnResolve = (result) => {
|
|
22
|
-
const status = statusOf(result);
|
|
23
|
-
return status === void 0 || status < 500;
|
|
24
|
-
};
|
|
25
|
-
var settledOnReject = (error) => {
|
|
26
|
-
const status = statusOf(error);
|
|
27
|
-
return status !== void 0 && status < 500;
|
|
28
|
-
};
|
|
29
|
-
var withIdempotencyKey = async (url, body, send) => {
|
|
30
|
-
const signature = `${url}
|
|
31
|
-
${body}`;
|
|
32
|
-
let entry = pending.get(signature);
|
|
33
|
-
if (!entry) {
|
|
34
|
-
entry = { key: mintKey(), inFlight: 0, keep: false };
|
|
35
|
-
if (pending.size >= MAX_PENDING) {
|
|
36
|
-
const oldest = pending.keys().next().value;
|
|
37
|
-
if (oldest !== void 0) pending.delete(oldest);
|
|
38
|
-
}
|
|
39
|
-
pending.set(signature, entry);
|
|
40
|
-
} else if (entry.inFlight === 0) {
|
|
41
|
-
entry.keep = false;
|
|
42
|
-
}
|
|
43
|
-
entry.inFlight += 1;
|
|
44
|
-
const settle = (settled) => {
|
|
45
|
-
entry.inFlight -= 1;
|
|
46
|
-
if (!settled) entry.keep = true;
|
|
47
|
-
if (entry.inFlight === 0 && !entry.keep) pending.delete(signature);
|
|
48
|
-
};
|
|
49
|
-
try {
|
|
50
|
-
const result = await send({ [HEADER]: entry.key });
|
|
51
|
-
settle(settledOnResolve(result));
|
|
52
|
-
return result;
|
|
53
|
-
} catch (error) {
|
|
54
|
-
settle(settledOnReject(error));
|
|
55
|
-
throw error;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// src/RedactoNoticeConsent/useMediaQuery.ts
|
|
60
|
-
import { useState, useEffect } from "react";
|
|
61
|
-
var useMediaQuery = (query) => {
|
|
62
|
-
const getMatches = () => typeof window !== "undefined" ? window.matchMedia(query).matches : false;
|
|
63
|
-
const [matches, setMatches] = useState(getMatches);
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
if (typeof window === "undefined") return;
|
|
66
|
-
const media = window.matchMedia(query);
|
|
67
|
-
const listener = (e) => {
|
|
68
|
-
setMatches(e.matches);
|
|
69
|
-
};
|
|
70
|
-
if (media.addEventListener) {
|
|
71
|
-
media.addEventListener("change", listener);
|
|
72
|
-
} else {
|
|
73
|
-
media.addListener(listener);
|
|
74
|
-
}
|
|
75
|
-
return () => {
|
|
76
|
-
if (media.removeEventListener) {
|
|
77
|
-
media.removeEventListener("change", listener);
|
|
78
|
-
} else {
|
|
79
|
-
media.removeListener(listener);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
}, [query]);
|
|
83
|
-
return matches;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
// src/shared/sandbox.ts
|
|
87
|
-
var SANDBOX_TOKEN_HEADER = "X-Consent-Token";
|
|
88
|
-
|
|
89
|
-
export {
|
|
90
|
-
SANDBOX_TOKEN_HEADER,
|
|
91
|
-
withIdempotencyKey,
|
|
92
|
-
useMediaQuery
|
|
93
|
-
};
|