Commit Graph

30 Commits

Author SHA1 Message Date
Émile Ré
0e3c79b0e8 Forward data-reopen-widget from script tag in IIFE entry point
Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-22 11:34:49 +04:00
Émile Ré
68fffbf2f3 Add reopen-widget attribute and probo-settings-link element
Allow customers to replace the built-in floating settings button with
their own re-open trigger (e.g. a footer link) by either placing a
<probo-settings-link> element anywhere on the page or manually setting
reopen-widget="custom" on the root. The settings-link auto-hides the
floating button on connect via a reopen-widget attribute change event.

Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-22 11:34:49 +04:00
Émile Ré
6391d276d9 Clean up settings button CSS custom properties
Remove undocumented --probo-settings-bottom variable and use the
shared --probo-z-index variable instead of --probo-settings-z-index.

Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-22 11:34:48 +04:00
Émile Ré
55d81e21eb Fix preference panel close returning to banner when consent exists
When a visitor with existing consent opened the preference panel via
the floating settings button and closed it, the state was always set
to "banner" instead of "hidden". Now check hasConsent so closing the
panel returns to the floating button when preferences are already saved.

Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-22 11:34:48 +04:00
Émile Ré
9ec6922fde Hide empty categories in cookie banner preference panel
Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-22 11:34:48 +04:00
Émile Ré
fab95413df Improve UI of themed banner
Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-22 11:34:48 +04:00
Émile Ré
7cd8c516b9 Add uncategorised cookie category
Replace the `required` boolean column on cookie_categories with a `kind`
enum (NORMAL, NECESSARY, UNCATEGORISED). The Necessary category remains
undeletable and always-on for consent; the new Uncategorised category is
also undeletable but users can opt out of it.

When a category is deleted, its cookies are merged into the Uncategorised
category (lazy-created for legacy banners that don't have one yet).

Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-21 11:40:21 +04:00
Émile Ré
80a4d44e6d Add CSS custom properties for font size and button radius
Expose --probo-font-size and --probo-btn-radius so customers
can scale typography and button shape without overriding
internals. The type scale now uses calc() offsets from the
base variable. The settings button defaults now follow
--probo-accent so a single accent change updates both the
banner and the floating button.

Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-20 10:52:36 +04:00
Émile Ré
0ab448691d Fix race between initClient and disconnectedCallback
Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-20 10:52:36 +04:00
Émile Ré
bc766ae5c9 Fix event listener and observer leaks in cookie banner
Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-20 10:52:35 +04:00
Émile Ré
11a63b5dec Add readme
Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-20 10:52:35 +04:00
Émile Ré
4da05b1368 Stop exposing internals
Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-20 10:52:35 +04:00
Émile Ré
1e306e5076 Rename default banner to themed banner
Rename src/default/ to src/themed-banner/, update class names
(ProboDefaultBanner → ProboThemedBanner), style constant
(DEFAULT_STYLES → THEMED_STYLES), registration function
(registerDefault → registerThemedBanner), and adjust build
entrypoints and package.json exports accordingly.

Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-20 10:52:35 +04:00
Émile Ré
2e066c82ad Remove shadow DOM from headless components
Headless components are behavioral wrappers meant to be styled
by the consumer with regular CSS. Shadow DOM on each child
created unnecessary style boundaries with no visual content to
protect. Only ProboSettingsButton retains its own shadow root
since it renders encapsulated styled markup.

Also removes the auto-registerComponents() side effect from
the main entrypoint so consumers opt in explicitly.

Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-20 10:52:35 +04:00
Émile Ré
f0b5a13f6f Use URL objects for API endpoint construction
Store baseUrl as URL and build endpoints with new URL(path, base).
Accept URL | string in fetchJSON to avoid unnecessary .href calls.

Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-20 10:52:35 +04:00
Émile Ré
ce77091e6c Add validation for preference panel and category template
Validate that <probo-preference-panel> contains <probo-category-list>
and <probo-save-button>, and that the category template includes
<probo-category-toggle> and <probo-cookie-list>.

Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-20 10:52:34 +04:00
Émile Ré
d802ee611f Add headless web components for cookie banner UI
Introduce Shadow DOM-based custom elements that let customers build
their own cookie banner and preference panel while the SDK validates
structural compliance and auto-renders categories/cookies from config.

Components: probo-cookie-banner (root), probo-banner, probo-accept-button,
probo-reject-button, probo-customize-button, probo-preference-panel,
probo-category-list, probo-category, probo-category-toggle,
probo-cookie-list, probo-cookie, probo-save-button, probo-settings-button.

Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-20 10:52:34 +04:00
Émile Ré
d63ce1f68b Fix expired queue entries persisting past MAX_AGE_MS
The flush function pruned expired entries in memory but re-read from
localStorage before writing back, so the age filter was never persisted.
Apply the age cutoff to the final write filter and remove the early
return that skipped the write entirely on full send failure.

Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-16 14:56:34 +04:00
Émile Ré
eafca11c82 Fix queue flush race condition and missing flush on cookie path
Re-read localStorage after network calls in flush() to avoid
discarding entries added by concurrent enqueue() calls. Also
call flush() in the cookie fast-path of load() so queued
consent retries are always drained.

Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-16 14:56:33 +04:00
Émile Ré
7d05d43f85 Fix review issues from automated code review
- Rename MAX_RETRIES to MAX_ATTEMPTS (3 total) to fix
  misleading naming
- Skip retry loop on caller-initiated aborts so explicit
  cancellations terminate immediately
- Preserve original script type via data-type attribute
  instead of always forcing text/javascript
- Recreate MutationObserver when consent changes so newly
  added elements use fresh consent data
- Fix package.json exports: point main at ESM bundle and
  add proper exports map with IIFE as separate entry

Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-16 14:56:33 +04:00
Émile Ré
75996d2dd6 Tune HTTP timeouts and add localStorage consent retry queue
Reduce timeout/retry defaults (5s timeout, 2 retries, 500ms base delay)
to cap worst-case page-load blocking at ~12s instead of ~36s.

Add a localStorage-backed queue that persists failed consent POSTs and
replays them on next page load, closing the compliance gap where a
network failure could permanently lose the server-side audit record.

Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-16 14:56:33 +04:00
Émile Ré
cb438c010d Fix polynomial regex CodeQL warning
Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-16 14:56:33 +04:00
Émile Ré
14d51b1fe4 Add consent-based element activation
Unblock scripts, iframes, images, and other resource-loading
elements marked with data-cookie-consent when their category
is consented. Uses MutationObserver for dynamically added
elements. Restricted to known resource tags with data-href
support for link elements.

Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-16 14:56:33 +04:00
Émile Ré
266446be9c Use getRandomValues for wider browser support
Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-16 14:56:32 +04:00
Émile Ré
c887e3497f Fix copyright headers
Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-16 14:56:32 +04:00
Émile Ré
0abde83a88 Extract visitor ID management into visitor.ts
Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-16 14:56:32 +04:00
Émile Ré
5cdf39c4f7 Add SDK client with consent cookie caching
CookieBannerClient wraps the cookie banner REST API with
methods to load config, accept/reject/customize consent,
and manage visitor identity. Consent state is persisted in
a probo_consent cookie to skip API calls on return visits,
with version-aware invalidation and configurable expiry.

Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-16 14:56:32 +04:00
Émile Ré
5b5c671eb1 Fix build.mjs copyright
Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-16 14:56:32 +04:00
Émile Ré
3b677d9464 Add HTTP client with retries and typed errors
Introduces fetchJSON<T> with timeout, exponential backoff
with jitter on network errors and 5xx/429, and error classes
that match the cookie banner API error shape.

Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-16 14:56:31 +04:00
Émile Ré
be1e94da71 Add @probo/cookie-banner SDK package scaffold
Introduce the boilerplate for a new public npm package that will
serve as the cookie consent banner JavaScript SDK. The package
uses esbuild to produce both an IIFE bundle (for script tag
embedding) and an ESM module. Versioning is independent from the
monorepo: CI compares package.json against npm and only publishes
when the version changes.

Signed-off-by: Émile Ré <emile@getprobo.com>
2026-04-16 14:56:31 +04:00