@smartgenie/cookie-consent 0.0.0-stage → 1.0.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.
Files changed (92) hide show
  1. package/LICENSE +73 -0
  2. package/README.md +292 -2
  3. package/dist/blocking/attribute-blocker.d.ts +18 -0
  4. package/dist/blocking/gtm-consent-mode.d.ts +19 -0
  5. package/dist/blocking/uet-consent.d.ts +9 -0
  6. package/dist/capsules/banner-experiment.d.ts +2 -0
  7. package/dist/capsules/banner-experiment.js +1 -0
  8. package/dist/capsules/country-banners.d.ts +2 -0
  9. package/dist/capsules/country-banners.js +1 -0
  10. package/dist/capsules/loader.d.ts +8 -0
  11. package/dist/capsules/subdomain-consent.d.ts +5 -0
  12. package/dist/capsules/subdomain-consent.js +1 -0
  13. package/dist/config/schema.d.ts +19 -0
  14. package/dist/config/validator.d.ts +8 -0
  15. package/dist/core/consent-log.d.ts +14 -0
  16. package/dist/core/consent-manager.d.ts +13 -0
  17. package/dist/core/consent-stats.d.ts +13 -0
  18. package/dist/core/events.d.ts +5 -0
  19. package/dist/core/gpc.d.ts +5 -0
  20. package/dist/core/storage.d.ts +9 -0
  21. package/dist/geo/detector.d.ts +3 -0
  22. package/dist/i18n/langs/ar.d.ts +1 -0
  23. package/dist/i18n/langs/cs.d.ts +1 -0
  24. package/dist/i18n/langs/da.d.ts +1 -0
  25. package/dist/i18n/langs/de.d.ts +1 -0
  26. package/dist/i18n/langs/es.d.ts +1 -0
  27. package/dist/i18n/langs/fr.d.ts +1 -0
  28. package/dist/i18n/langs/hi.d.ts +1 -0
  29. package/dist/i18n/langs/it.d.ts +1 -0
  30. package/dist/i18n/langs/ja.d.ts +1 -0
  31. package/dist/i18n/langs/ko.d.ts +1 -0
  32. package/dist/i18n/langs/nl.d.ts +1 -0
  33. package/dist/i18n/langs/no.d.ts +1 -0
  34. package/dist/i18n/langs/pl.d.ts +1 -0
  35. package/dist/i18n/langs/pt.d.ts +1 -0
  36. package/dist/i18n/langs/ro.d.ts +1 -0
  37. package/dist/i18n/langs/ru.d.ts +1 -0
  38. package/dist/i18n/langs/sv.d.ts +1 -0
  39. package/dist/i18n/langs/tr.d.ts +1 -0
  40. package/dist/i18n/langs/zh.d.ts +1 -0
  41. package/dist/i18n/loader.d.ts +11 -0
  42. package/dist/i18n/remote.d.ts +23 -0
  43. package/dist/i18n/translations.d.ts +14 -0
  44. package/dist/index.d.ts +10 -0
  45. package/dist/lang/ar.json +1 -0
  46. package/dist/lang/cs.json +1 -0
  47. package/dist/lang/da.json +1 -0
  48. package/dist/lang/de.json +1 -0
  49. package/dist/lang/es.json +1 -0
  50. package/dist/lang/fr.json +1 -0
  51. package/dist/lang/hi.json +1 -0
  52. package/dist/lang/it.json +1 -0
  53. package/dist/lang/ja.json +1 -0
  54. package/dist/lang/ko.json +1 -0
  55. package/dist/lang/nl.json +1 -0
  56. package/dist/lang/no.json +1 -0
  57. package/dist/lang/pl.json +1 -0
  58. package/dist/lang/pt.json +1 -0
  59. package/dist/lang/ro.json +1 -0
  60. package/dist/lang/ru.json +1 -0
  61. package/dist/lang/sv.json +1 -0
  62. package/dist/lang/tr.json +1 -0
  63. package/dist/lang/zh.json +1 -0
  64. package/dist/react/SmartConsent.d.ts +14 -0
  65. package/dist/react/SmartConsent.js +2260 -0
  66. package/dist/react/SmartConsent.js.map +1 -0
  67. package/dist/regulations/loader.d.ts +3 -0
  68. package/dist/regulations/reasoner.d.ts +6 -0
  69. package/dist/regulations/schema.d.ts +8 -0
  70. package/dist/site/consent-records.d.ts +26 -0
  71. package/dist/site/settings.d.ts +48 -0
  72. package/dist/smartconsent.es.js +3063 -0
  73. package/dist/smartconsent.es.js.map +1 -0
  74. package/dist/smartconsent.js +3962 -0
  75. package/dist/smartconsent.js.map +1 -0
  76. package/dist/smartconsent.min.js +534 -0
  77. package/dist/smartconsent.min.js.map +1 -0
  78. package/dist/types.d.ts +377 -0
  79. package/dist/ui/a11y.d.ts +4 -0
  80. package/dist/ui/attribution-guard.d.ts +3 -0
  81. package/dist/ui/badge.d.ts +7 -0
  82. package/dist/ui/banner.d.ts +10 -0
  83. package/dist/ui/cookie-policy.d.ts +8 -0
  84. package/dist/ui/cookie-table.d.ts +7 -0
  85. package/dist/ui/credit.d.ts +15 -0
  86. package/dist/ui/embed-placeholder.d.ts +7 -0
  87. package/dist/ui/opt-out-notice.d.ts +7 -0
  88. package/dist/ui/styles.d.ts +3 -0
  89. package/dist/webhook.d.ts +5 -0
  90. package/package.json +100 -4
  91. package/templates/privacy-policy-template.md +135 -0
  92. package/templates/vanilla.html +116 -0
@@ -0,0 +1,377 @@
1
+ /** How consent was given or changed */
2
+ export type ConsentAction = 'accept_all' | 'reject_optional' | 'custom' | 'withdraw';
3
+ /** A single cookie category definition */
4
+ export interface ConsentCategory {
5
+ id: string;
6
+ label: string;
7
+ description: string;
8
+ required: boolean;
9
+ }
10
+ /** Persisted consent state (stored in localStorage) */
11
+ export interface ConsentState {
12
+ version: number;
13
+ categories: Record<string, boolean>;
14
+ timestamp: string;
15
+ action: ConsentAction;
16
+ expiresAt: string;
17
+ }
18
+ /** Payload dispatched with the smartconsent:update CustomEvent */
19
+ export interface ConsentEvent {
20
+ categories: Record<string, boolean>;
21
+ action: ConsentAction;
22
+ timestamp: string;
23
+ version: number;
24
+ }
25
+ /** A single consent event record (FP-01: Consent Log) */
26
+ export interface ConsentRecord {
27
+ id: string;
28
+ timestamp: string;
29
+ action: ConsentAction;
30
+ categories: Record<string, boolean>;
31
+ visitorHash: string;
32
+ version: string;
33
+ jurisdiction: string;
34
+ }
35
+ /** Body sent to the API for each choice on a site with a site ID, any plan (CR-019, BRIEF-070, BRIEF-101); never the IP */
36
+ export interface ConsentRecordPayload {
37
+ site_id: string;
38
+ consent_id: string;
39
+ visitor_id: string;
40
+ visitor_id_persisted: boolean;
41
+ timestamp: string;
42
+ action: ConsentAction;
43
+ categories: Record<string, boolean>;
44
+ consent_version: string;
45
+ jurisdiction: string;
46
+ gpc: boolean;
47
+ language: string;
48
+ wording: {
49
+ heading: string;
50
+ description: string;
51
+ acceptAll: string;
52
+ rejectOptional: string;
53
+ managePreferences: string;
54
+ essentialOnly: string;
55
+ savePreferences: string;
56
+ categories: Record<string, string>;
57
+ };
58
+ page_url: string;
59
+ engine_version: string;
60
+ /** While a banner A/B test runs and this visitor was split (CR-047): the test id and the variant shown */
61
+ experiment?: string;
62
+ variant?: 'a' | 'b';
63
+ /** Path only, at most 200 characters; sent only during a banner A/B test. */
64
+ page?: string;
65
+ }
66
+ /** Payload POSTed to the webhook endpoint */
67
+ export interface WebhookPayload {
68
+ action: ConsentAction;
69
+ categories: Record<string, boolean>;
70
+ version: number;
71
+ timestamp: string;
72
+ pageUrl: string;
73
+ userAgent: string;
74
+ recordId?: string;
75
+ visitorHash?: string;
76
+ jurisdiction?: string;
77
+ }
78
+ /** Theme overrides — each key maps to a --sc-* CSS variable */
79
+ export interface SmartConsentTheme {
80
+ bg: string;
81
+ surface: string;
82
+ border: string;
83
+ text: string;
84
+ textMuted: string;
85
+ accent: string;
86
+ accept: string;
87
+ reject: string;
88
+ toggleOn: string;
89
+ toggleOff: string;
90
+ radius: string;
91
+ font: string;
92
+ }
93
+ /** All UI strings — enables localisation without touching UI code */
94
+ export interface SmartConsentTexts {
95
+ heading: string;
96
+ description: string;
97
+ acceptAll: string;
98
+ rejectOptional: string;
99
+ managePreferences: string;
100
+ essentialOnly: string;
101
+ savePreferences: string;
102
+ poweredBy: string;
103
+ /** US opt-out notice links (CR-037): shown when every matched rule file is opt-out */
104
+ doNotSell: string;
105
+ cookieSettings: string;
106
+ /** Link to the site's visitor data-request page (CR-034) */
107
+ dataRequest: string;
108
+ /** Credit line at the end of the generated cookie policy (CR-009) */
109
+ policyCredit: string;
110
+ /** Placeholder for a held embed (CR-035); `{service}` is replaced by the embed's host */
111
+ embedNotice: string;
112
+ embedLoad: string;
113
+ }
114
+ /** A manually declared cookie (FP-07) */
115
+ export interface CookieDeclaration {
116
+ name: string;
117
+ category: string;
118
+ domain?: string;
119
+ description?: string;
120
+ duration?: string;
121
+ party?: 'first' | 'third';
122
+ }
123
+ /** Banner position on the page */
124
+ export type BannerPosition = 'bottom' | 'top';
125
+ /** Banner layout style (FP-06) */
126
+ export type BannerLayout = 'banner' | 'box' | 'popup';
127
+ /** Box layout corner position (FP-06) */
128
+ export type BoxPosition = 'bottom-left' | 'bottom-right';
129
+ /** Persistent badge position */
130
+ export type BadgePosition = 'bottom-right' | 'bottom-left';
131
+ type PackOptional = 'policyCredit' | 'doNotSell' | 'cookieSettings' | 'embedNotice' | 'embedLoad' | 'dataRequest';
132
+ /** Language translation data (FP-03: i18n) */
133
+ export interface LanguageData {
134
+ lang: string;
135
+ dir: 'ltr' | 'rtl';
136
+ /** `policyCredit` and the opt-out link texts are optional here: a pack without them keeps the English defaults */
137
+ texts: Omit<SmartConsentTexts, PackOptional> & Partial<Pick<SmartConsentTexts, PackOptional>>;
138
+ categories: Record<string, {
139
+ label: string;
140
+ description: string;
141
+ }>;
142
+ }
143
+ /** Full SmartConsent configuration (section 3.9 of ARCHITECTURE.md) */
144
+ export interface SmartConsentConfig {
145
+ version: number;
146
+ categories: ConsentCategory[];
147
+ theme: SmartConsentTheme;
148
+ position: BannerPosition;
149
+ badgePosition: BadgePosition;
150
+ showBadge: boolean;
151
+ attribution: boolean;
152
+ attributionUrl: string;
153
+ consentMode: boolean;
154
+ webhookUrl?: string;
155
+ expiry: number;
156
+ onConsent?: (state: ConsentState) => void;
157
+ texts: SmartConsentTexts;
158
+ language?: string;
159
+ dir: 'ltr' | 'rtl';
160
+ layout: BannerLayout;
161
+ boxPosition: BoxPosition;
162
+ logo?: {
163
+ src: string;
164
+ alt: string;
165
+ width?: number;
166
+ height?: number;
167
+ };
168
+ cookies: CookieDeclaration[];
169
+ /** Site identifier (CR-012); alternatively `data-site-id` on the SmartConsent script tag */
170
+ siteId?: string;
171
+ /** Pages run by the WordPress plugin, the Joomla extension or the Drupal module keep the site owner's attribution choice. */
172
+ platform?: 'wordpress-plugin' | 'joomla-extension' | 'drupal-module';
173
+ /** Referral code for the badge link (CR-027); set only by applySiteSettings from a fetched settings file, never the page */
174
+ attributionRef?: string;
175
+ /** Same-site address that receives consent records instead of SmartGenie (BRIEF-108); page config only */
176
+ recordsEndpoint?: string;
177
+ /** The site's visitor data-request page (CR-034); set only by the engine from the settings file's `requests` flag */
178
+ dataRequestUrl?: string;
179
+ }
180
+ /** Plan in a per-site settings file (CR-012) */
181
+ export type SitePlan = 'free' | 'pro' | 'enterprise';
182
+ /** Mode in a per-site settings file: `safe` keeps the banner and forces attribution except on WordPress, Joomla and Drupal pages. */
183
+ export type SiteMode = 'normal' | 'safe';
184
+ /** One known-tracker rule (CR-035): a lower-case pattern and the category it is held under */
185
+ export type BlockRule = [string, 'analytics' | 'marketing'];
186
+ /** Per-site settings file served at `<settingsBase>/v1/sites/<id>.json` (CR-012) */
187
+ export interface SiteSettings {
188
+ version: 1;
189
+ plan: SitePlan;
190
+ mode: SiteMode;
191
+ /** `required` is true for every Free and Pro site except a WordPress plugin site that registered itself (BRIEF-122) */
192
+ /** `ref` (the site ID) and `host` only when the link is required (CR-027): the badge links to us with `?ref=<ref>` on that host */
193
+ attribution: {
194
+ required: boolean;
195
+ ref?: string;
196
+ host?: string;
197
+ };
198
+ /** The site's registered host: limits a Free or Pro opt-out unless the page is run by the WordPress plugin. */
199
+ host?: string;
200
+ /**
201
+ * Known trackers to hold back (CR-035): `[pattern, category]` pairs, at most 300, the same for every site the
202
+ * `auto_blocking` capsule allows. A pattern with `/` matches anywhere in host plus path, any other the host or a
203
+ * subdomain; the first match wins. Absent when the capsule is off. The engine holds matching scripts and iframes.
204
+ */
205
+ block?: BlockRule[];
206
+ /** The customer's banner look from the dashboard (CR-018); wins over the page config for the fields it sets */
207
+ banner?: {
208
+ /** Pro and Enterprise only (BRIEF-101): an https image and its alt text */
209
+ logo?: {
210
+ src: string;
211
+ alt: string;
212
+ };
213
+ /** Banner language code (any plan); packs load from the CDN (BRIEF-105) */
214
+ language?: string;
215
+ /** Pro and Enterprise only: the languages offered to visitors; an empty list means only `language` */
216
+ languages?: string[];
217
+ theme?: Partial<SmartConsentTheme>;
218
+ layout?: BannerLayout;
219
+ position?: BannerPosition;
220
+ boxPosition?: BoxPosition;
221
+ texts?: Partial<Pick<SmartConsentTexts, 'heading' | 'description' | 'acceptAll' | 'rejectOptional' | 'managePreferences' | 'essentialOnly' | 'savePreferences'>>;
222
+ };
223
+ /** Pro (CR-042): a look per region; `ids` are rule file ids. Fields left out keep the main `banner` look. */
224
+ regions?: RegionLook[];
225
+ /** The engine capsules this site loads from the CDN (`capsules/<id>.js` beside the engine), set by our server */
226
+ capsules?: string[];
227
+ /** Pro (CR-046, ruling 65): one consent across this domain and its subdomains, kept in the `sc_consent` cookie */
228
+ share?: {
229
+ domain: string;
230
+ };
231
+ /** Pro (CR-047): a running banner A/B test; `b` is version B's look (the main look's fields except logo and languages) */
232
+ experiment?: {
233
+ id: string;
234
+ b: RegionLook['look'];
235
+ };
236
+ /** Every plan, when the data-requests capsule is on (CR-034): the banner links to this site's request page */
237
+ requests?: boolean;
238
+ }
239
+ /** One region's banner look (CR-042): the main look's fields except logo and languages */
240
+ export interface RegionLook {
241
+ ids: string[];
242
+ look: Omit<NonNullable<SiteSettings['banner']>, 'logo' | 'language' | 'languages'>;
243
+ }
244
+ /** What an engine capsule file hands over on `window.SmartConsentCapsules[id]` (CR-042) */
245
+ export interface EngineCapsule {
246
+ v: number;
247
+ apply: (ids: string[], regions: unknown) => unknown;
248
+ }
249
+ /** What the subdomain-consent capsule hands over (CR-046): reads and writes the one `sc_consent` cookie on `domain` */
250
+ export interface SubdomainConsentCapsule {
251
+ v: number;
252
+ read: (domain: string) => ConsentState | null;
253
+ write: (domain: string, state: ConsentState | null) => void;
254
+ }
255
+ /** What the banner-experiment capsule hands over (CR-047): the visitor's variant of test `id` */
256
+ export interface BannerExperimentCapsule {
257
+ v: number;
258
+ pick: (vid: string | null, id: string) => 'a' | 'b';
259
+ }
260
+ /** Public API exposed on window.SmartConsent */
261
+ export interface SmartConsentAPI {
262
+ hasConsent(category: string): boolean;
263
+ getConsent(): ConsentState | null;
264
+ getConsentLog(): ConsentRecord[];
265
+ getLatestConsent(): ConsentRecord | null;
266
+ getConsentStats(): import('./core/consent-stats').ConsentStats;
267
+ getCookies(): CookieDeclaration[];
268
+ renderCookieTable(selector: string): void;
269
+ getCookieTableHTML(): string;
270
+ generateCookiePolicy(options: {
271
+ siteName: string;
272
+ siteUrl: string;
273
+ contactEmail: string;
274
+ }): string;
275
+ renderCookiePolicy(selector: string, options: {
276
+ siteName: string;
277
+ siteUrl: string;
278
+ contactEmail: string;
279
+ }): void;
280
+ show(): void;
281
+ reset(): void;
282
+ }
283
+ /** Jurisdiction scope for a regulation */
284
+ export interface RegulationJurisdiction {
285
+ countries: string[];
286
+ states?: string[] | null;
287
+ }
288
+ /** Banner UI requirements mandated by a regulation */
289
+ export interface RegulationBannerRequirements {
290
+ require_accept_button: boolean;
291
+ require_reject_button: boolean;
292
+ require_equal_prominence: boolean;
293
+ require_customise_button: boolean;
294
+ cookie_wall_permitted: boolean;
295
+ require_granular_categories: boolean;
296
+ }
297
+ /** Consent lifecycle rules mandated by a regulation */
298
+ export interface RegulationConsentRules {
299
+ expiry_days: number;
300
+ withdrawal_mechanism: string;
301
+ withdrawal_ease: string;
302
+ re_consent_on_policy_change: boolean;
303
+ }
304
+ /** Language requirements for a regulation */
305
+ export interface RegulationLanguage {
306
+ mandatory_languages: string[];
307
+ auto_detect_browser_language: boolean;
308
+ }
309
+ /** Browser signal support mandated by a regulation */
310
+ export interface RegulationSignals {
311
+ honour_gpc: boolean;
312
+ honour_dnt: boolean;
313
+ }
314
+ /** Child protection requirements for a regulation */
315
+ export interface RegulationChildren {
316
+ age_threshold: number;
317
+ tracking_prohibited: boolean;
318
+ parental_consent_required: boolean;
319
+ }
320
+ /** Audit and record-keeping requirements */
321
+ export interface RegulationAudit {
322
+ consent_log_required: boolean;
323
+ retention_years: number | null;
324
+ proof_of_consent_required: boolean;
325
+ }
326
+ /** Full regulation data — one per JSON file in the Knowledge Graph */
327
+ export interface RegulationData {
328
+ id: string;
329
+ name: string;
330
+ consent_model: 'opt-in' | 'opt-out';
331
+ default_cookie_state: 'blocked' | 'allowed';
332
+ version: string;
333
+ last_updated: string;
334
+ sources: string[];
335
+ jurisdiction: RegulationJurisdiction;
336
+ banner_requirements: RegulationBannerRequirements;
337
+ consent_rules: RegulationConsentRules;
338
+ language: RegulationLanguage;
339
+ signals: RegulationSignals;
340
+ children: RegulationChildren;
341
+ audit: RegulationAudit;
342
+ }
343
+ /** Output of the Consent Reasoner — derived from geo + regulation data */
344
+ export interface BannerConfiguration {
345
+ mode: 'opt-in' | 'opt-out';
346
+ buttons: {
347
+ accept_all: boolean;
348
+ reject_all: boolean;
349
+ customise: boolean;
350
+ equal_prominence: boolean;
351
+ };
352
+ categories: ConsentCategory[];
353
+ blocking: {
354
+ mode: 'block-first';
355
+ unknown_scripts: 'blocked' | 'allowed';
356
+ };
357
+ consent: {
358
+ expiry_days: number;
359
+ withdrawal_mechanism: string;
360
+ re_consent_on_version_change: boolean;
361
+ };
362
+ signals: {
363
+ gpc_auto_reject: boolean;
364
+ };
365
+ cookie_wall: boolean;
366
+ language: string;
367
+ applicable_regulations: string[];
368
+ /** The matched rule files' ids, in the same order (`default-global` on fallback); picks the region look (CR-042) */
369
+ regulation_ids: string[];
370
+ }
371
+ /** Geo-detection result */
372
+ export interface GeoResult {
373
+ country: string;
374
+ state?: string;
375
+ source: 'timezone' | 'cache' | 'fallback';
376
+ }
377
+ export {};
@@ -0,0 +1,4 @@
1
+ /** Traps focus within a container element. Returns a release function. */
2
+ export declare function trapFocus(container: HTMLElement): () => void;
3
+ /** Announces a message to screen readers via an aria-live region. */
4
+ export declare function announceToScreenReader(message: string): void;
@@ -0,0 +1,3 @@
1
+ import type { SmartConsentConfig } from '../types';
2
+ /** Starts guarding the banner's attribution links. Returns a function that stops the guard. */
3
+ export declare function guardAttribution(banner: HTMLElement, config: SmartConsentConfig): () => void;
@@ -0,0 +1,7 @@
1
+ import type { SmartConsentConfig } from '../types';
2
+ export interface BadgeAPI {
3
+ show(): void;
4
+ hide(): void;
5
+ destroy(): void;
6
+ }
7
+ export declare function createBadge(config: SmartConsentConfig, onOpen: () => void): BadgeAPI;
@@ -0,0 +1,10 @@
1
+ import type { ConsentManager } from '../core/consent-manager';
2
+ import type { SmartConsentConfig } from '../types';
3
+ export interface BannerAPI {
4
+ show(): void;
5
+ hide(): void;
6
+ destroy(): void;
7
+ }
8
+ /** Appends "Your data rights" (CR-034) when the engine set the site's request page address; " · " after the credit. */
9
+ export declare function appendDataRightsLink(box: HTMLElement, config: SmartConsentConfig): void;
10
+ export declare function createBanner(manager: ConsentManager, config: SmartConsentConfig): BannerAPI;
@@ -0,0 +1,8 @@
1
+ import type { SmartConsentConfig } from '../types';
2
+ export interface PolicyOptions {
3
+ siteName: string;
4
+ siteUrl: string;
5
+ contactEmail: string;
6
+ }
7
+ export declare function generateCookiePolicy(config: SmartConsentConfig, options: PolicyOptions): string;
8
+ export declare function renderCookiePolicy(selector: string, config: SmartConsentConfig, options: PolicyOptions): void;
@@ -0,0 +1,7 @@
1
+ import type { CookieDeclaration, SmartConsentConfig } from '../types';
2
+ /** Marks a cookie as found by our scan; returns it. */
3
+ export declare function markScanned(c: CookieDeclaration): CookieDeclaration;
4
+ /** Build cookie table HTML string grouped by category. */
5
+ export declare function buildCookieTableHTML(config: SmartConsentConfig): string;
6
+ /** Render cookie table into a DOM element. */
7
+ export declare function renderCookieTable(selector: string, config: SmartConsentConfig): void;
@@ -0,0 +1,15 @@
1
+ import type { SmartConsentConfig } from '../types';
2
+ /**
3
+ * The `poweredBy` text of each built-in language pack (src/i18n/langs). A constant, not the runtime registry:
4
+ * a page can register its own language, and packs are opt-in imports. tests/ui/credit-drift.test.ts keeps it in step.
5
+ */
6
+ export declare const CREDIT_TRANSLATIONS: Record<string, string>;
7
+ /** The URL unchanged when it is an absolute http: or https: URL; otherwise null (javascript:, data:, relative, ...). */
8
+ export declare function safeHttpUrl(url: unknown): string | null;
9
+ /** The badge links' rel (CR-027): a paid-for link to us, never followed by search engines. */
10
+ export declare const CREDIT_REL = "sponsored nofollow noopener";
11
+ /** The badge link: the safe attribution URL, or our referral redirect page `/r/<code>` when the settings file gave this
12
+ * site a code (CR-027, BRIEF-154: the website records the click and carries it to sign-up). */
13
+ export declare function creditHref(config: SmartConsentConfig): string | null;
14
+ /** Credit wording to show: the configured text if approved (default or built-in translation), else the default for the visitor's language. */
15
+ export declare function creditText(config: SmartConsentConfig, key: 'poweredBy' | 'policyCredit'): string;
@@ -0,0 +1,7 @@
1
+ import type { SmartConsentTexts } from '../types';
2
+ type EmbedTexts = Pick<SmartConsentTexts, 'embedNotice' | 'embedLoad'>;
3
+ /** A box the size of `frame`; `onLoad` runs when the visitor asks for this embed. Fill it with `fillPlaceholder`. */
4
+ export declare function createPlaceholder(frame: HTMLIFrameElement, onLoad: () => void): HTMLElement;
5
+ /** Writes (or rewrites) the box's sentence and button for the embed's host. */
6
+ export declare function fillPlaceholder(box: HTMLElement, service: string, t: EmbedTexts): void;
7
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { ConsentManager } from '../core/consent-manager';
2
+ import type { SmartConsentConfig } from '../types';
3
+ export interface NoticeAPI {
4
+ show(): void;
5
+ hide(): void;
6
+ }
7
+ export declare function createOptOutNotice(manager: ConsentManager, config: SmartConsentConfig, openSettings: () => void): NoticeAPI;
@@ -0,0 +1,3 @@
1
+ import type { SmartConsentTheme } from '../types';
2
+ export declare function injectStyles(theme: SmartConsentTheme): void;
3
+ export declare function removeStyles(): void;
@@ -0,0 +1,5 @@
1
+ import type { ConsentEvent, ConsentRecord, SmartConsentConfig } from './types';
2
+ export interface WebhookAPI {
3
+ send(event: ConsentEvent, record?: ConsentRecord): void;
4
+ }
5
+ export declare function createWebhook(config: SmartConsentConfig): WebhookAPI;
package/package.json CHANGED
@@ -1,6 +1,102 @@
1
1
  {
2
2
  "name": "@smartgenie/cookie-consent",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "SmartGenie Cookie Consent: an ask-first cookie consent banner that holds back the scripts you mark until the visitor agrees, sends Google Consent Mode v2 and Microsoft UET consent signals, and honours Global Privacy Control and Do Not Track in every region. Zero runtime dependencies.",
5
+ "type": "module",
6
+ "main": "dist/smartconsent.min.js",
7
+ "module": "dist/smartconsent.es.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/smartconsent.es.js"
13
+ },
14
+ "./react": {
15
+ "types": "./dist/react/SmartConsent.d.ts",
16
+ "import": "./dist/react/SmartConsent.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist/",
21
+ "templates/",
22
+ "LICENSE",
23
+ "README.md"
24
+ ],
25
+ "scripts": {
26
+ "dev": "vite",
27
+ "build": "vite build --mode unminified && vite build --mode minified && vite build --config vite.config.react.ts && tsc -p tsconfig.build.json && node scripts/build-lang-packs.mjs",
28
+ "build:sri": "node scripts/generate-sri.js",
29
+ "build:block-rules": "node scripts/build-block-rules.mjs",
30
+ "test": "vitest run",
31
+ "test:all": "node scripts/run-all-tests.mjs",
32
+ "test:affected": "node scripts/affected-tests.mjs",
33
+ "test:one": "node scripts/test-one.mjs",
34
+ "accept:check": "node scripts/accept-check.mjs",
35
+ "accept:brief": "node scripts/accept-brief.mjs",
36
+ "accept:queue": "node scripts/accept-queue.mjs",
37
+ "gate:batch": "node scripts/gate-batch.mjs",
38
+ "watch": "node scripts/watch.mjs",
39
+ "conduct": "node scripts/conductor.mjs",
40
+ "test:watch": "vitest",
41
+ "test:coverage": "vitest run --coverage",
42
+ "lint": "eslint \"src/**/*.ts\" \"tests/**/*.ts\"",
43
+ "format": "prettier --write src/**/*.ts tests/**/*.ts",
44
+ "format:check": "prettier --check src/**/*.ts tests/**/*.ts",
45
+ "typecheck": "tsc --noEmit",
46
+ "prepublishOnly": "npm run build && npm run test"
47
+ },
48
+ "peerDependencies": {
49
+ "react": ">=18.0.0",
50
+ "react-dom": ">=18.0.0"
51
+ },
52
+ "peerDependenciesMeta": {
53
+ "react": {
54
+ "optional": true
55
+ },
56
+ "react-dom": {
57
+ "optional": true
58
+ }
59
+ },
60
+ "devDependencies": {
61
+ "@testing-library/jest-dom": "^6.9.1",
62
+ "@testing-library/react": "^16.3.2",
63
+ "@types/react": "^19.2.14",
64
+ "@types/react-dom": "^19.2.3",
65
+ "@typescript-eslint/eslint-plugin": "^7.0.0",
66
+ "@typescript-eslint/parser": "^7.0.0",
67
+ "@vitest/coverage-v8": "^1.6.0",
68
+ "eslint": "^8.57.0",
69
+ "eslint-config-prettier": "^9.1.0",
70
+ "jsdom": "^24.0.0",
71
+ "playwright": "^1.59.1",
72
+ "prettier": "^3.2.0",
73
+ "react": "^19.2.4",
74
+ "react-dom": "^19.2.4",
75
+ "typescript": "^5.4.0",
76
+ "vite": "^5.4.0",
77
+ "vitest": "^1.6.0"
78
+ },
79
+ "keywords": [
80
+ "cookie-consent",
81
+ "gdpr",
82
+ "pecr",
83
+ "dpdp",
84
+ "privacy",
85
+ "consent-management",
86
+ "cookie-banner",
87
+ "google-consent-mode",
88
+ "global-privacy-control"
89
+ ],
90
+ "license": "BSL-1.1",
91
+ "repository": {
92
+ "type": "git",
93
+ "url": "https://github.com/Smartgenie-ltd/SmartConsent.git"
94
+ },
95
+ "homepage": "https://www.smartgenie.co.uk/smartconsent",
96
+ "bugs": {
97
+ "email": "hello@smartgenie.co.uk"
98
+ },
99
+ "publishConfig": {
100
+ "access": "public"
101
+ }
102
+ }