Files
breakpilot-core/docs-src/consent-sdk/dist/react/index.d.mts
Benjamin Boenisch ad111d5e69 Initial commit: breakpilot-core - Shared Infrastructure
Docker Compose with 24+ services:
- PostgreSQL (PostGIS), Valkey, MinIO, Qdrant
- Vault (PKI/TLS), Nginx (Reverse Proxy)
- Backend Core API, Consent Service, Billing Service
- RAG Service, Embedding Service
- Gitea, Woodpecker CI/CD
- Night Scheduler, Health Aggregator
- Jitsi (Web/XMPP/JVB/Jicofo), Mailpit

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 23:47:13 +01:00

451 lines
12 KiB
TypeScript

import * as react from 'react';
import { FC, ReactNode } from 'react';
/**
* Consent SDK Types
*
* DSGVO/TTDSG-konforme Typdefinitionen für das Consent Management System.
*/
/**
* Standard-Consent-Kategorien nach IAB TCF 2.2
*/
type ConsentCategory = 'essential' | 'functional' | 'analytics' | 'marketing' | 'social';
/**
* Consent-Status pro Kategorie
*/
type ConsentCategories = Record<ConsentCategory, boolean>;
/**
* Consent-Status pro Vendor
*/
type ConsentVendors = Record<string, boolean>;
/**
* Aktueller Consent-Zustand
*/
interface ConsentState {
/** Consent pro Kategorie */
categories: ConsentCategories;
/** Consent pro Vendor (optional, für granulare Kontrolle) */
vendors: ConsentVendors;
/** Zeitstempel der letzten Aenderung */
timestamp: string;
/** SDK-Version bei Erstellung */
version: string;
/** Eindeutige Consent-ID vom Backend */
consentId?: string;
/** Ablaufdatum */
expiresAt?: string;
/** IAB TCF String (falls aktiviert) */
tcfString?: string;
}
/**
* Minimaler Consent-Input fuer setConsent()
*/
type ConsentInput = Partial<ConsentCategories> | {
categories?: Partial<ConsentCategories>;
vendors?: ConsentVendors;
};
/**
* UI-Position des Banners
*/
type BannerPosition = 'bottom' | 'top' | 'center';
/**
* Banner-Layout
*/
type BannerLayout = 'bar' | 'modal' | 'floating';
/**
* Farbschema
*/
type BannerTheme = 'light' | 'dark' | 'auto';
/**
* UI-Konfiguration
*/
interface ConsentUIConfig {
/** Position des Banners */
position?: BannerPosition;
/** Layout-Typ */
layout?: BannerLayout;
/** Farbschema */
theme?: BannerTheme;
/** Pfad zu Custom CSS */
customCss?: string;
/** z-index fuer Banner */
zIndex?: number;
/** Scroll blockieren bei Modal */
blockScrollOnModal?: boolean;
/** Custom Container-ID */
containerId?: string;
}
/**
* Consent-Verhaltens-Konfiguration
*/
interface ConsentBehaviorConfig {
/** Muss Nutzer interagieren? */
required?: boolean;
/** "Alle ablehnen" Button sichtbar */
rejectAllVisible?: boolean;
/** "Alle akzeptieren" Button sichtbar */
acceptAllVisible?: boolean;
/** Einzelne Kategorien waehlbar */
granularControl?: boolean;
/** Einzelne Vendors waehlbar */
vendorControl?: boolean;
/** Auswahl speichern */
rememberChoice?: boolean;
/** Speicherdauer in Tagen */
rememberDays?: number;
/** Nur in EU anzeigen (Geo-Targeting) */
geoTargeting?: boolean;
/** Erneut nachfragen nach X Tagen */
recheckAfterDays?: number;
}
/**
* TCF 2.2 Konfiguration
*/
interface TCFConfig {
/** TCF aktivieren */
enabled?: boolean;
/** CMP ID */
cmpId?: number;
/** CMP Version */
cmpVersion?: number;
}
/**
* PWA-spezifische Konfiguration
*/
interface PWAConfig {
/** Offline-Unterstuetzung aktivieren */
offlineSupport?: boolean;
/** Bei Reconnect synchronisieren */
syncOnReconnect?: boolean;
/** Cache-Strategie */
cacheStrategy?: 'stale-while-revalidate' | 'network-first' | 'cache-first';
}
/**
* Haupt-Konfiguration fuer ConsentManager
*/
interface ConsentConfig {
/** API-Endpunkt fuer Consent-Backend */
apiEndpoint: string;
/** Site-ID */
siteId: string;
/** Sprache (ISO 639-1) */
language?: string;
/** Fallback-Sprache */
fallbackLanguage?: string;
/** UI-Konfiguration */
ui?: ConsentUIConfig;
/** Consent-Verhaltens-Konfiguration */
consent?: ConsentBehaviorConfig;
/** Aktive Kategorien */
categories?: ConsentCategory[];
/** TCF 2.2 Konfiguration */
tcf?: TCFConfig;
/** PWA-Konfiguration */
pwa?: PWAConfig;
/** Callback bei Consent-Aenderung */
onConsentChange?: (consent: ConsentState) => void;
/** Callback wenn Banner angezeigt wird */
onBannerShow?: () => void;
/** Callback wenn Banner geschlossen wird */
onBannerHide?: () => void;
/** Callback bei Fehler */
onError?: (error: Error) => void;
/** Debug-Modus aktivieren */
debug?: boolean;
}
/**
* Event-Typen
*/
type ConsentEventType = 'init' | 'change' | 'accept_all' | 'reject_all' | 'save_selection' | 'banner_show' | 'banner_hide' | 'settings_open' | 'settings_close' | 'vendor_enable' | 'vendor_disable' | 'error';
/**
* Event-Listener Callback
*/
type ConsentEventCallback<T = unknown> = (data: T) => void;
/**
* Event-Daten fuer verschiedene Events
*/
type ConsentEventData = {
init: ConsentState | null;
change: ConsentState;
accept_all: ConsentState;
reject_all: ConsentState;
save_selection: ConsentState;
banner_show: undefined;
banner_hide: undefined;
settings_open: undefined;
settings_close: undefined;
vendor_enable: string;
vendor_disable: string;
error: Error;
};
/**
* ConsentManager - Hauptklasse fuer das Consent Management
*
* DSGVO/TTDSG-konformes Consent Management fuer Web, PWA und Mobile.
*/
/**
* ConsentManager - Zentrale Klasse fuer Consent-Verwaltung
*/
declare class ConsentManager {
private config;
private storage;
private scriptBlocker;
private api;
private events;
private currentConsent;
private initialized;
private bannerVisible;
private deviceFingerprint;
constructor(config: ConsentConfig);
/**
* SDK initialisieren
*/
init(): Promise<void>;
/**
* Pruefen ob Consent fuer Kategorie vorhanden
*/
hasConsent(category: ConsentCategory): boolean;
/**
* Pruefen ob Consent fuer Vendor vorhanden
*/
hasVendorConsent(vendorId: string): boolean;
/**
* Aktuellen Consent-State abrufen
*/
getConsent(): ConsentState | null;
/**
* Consent setzen
*/
setConsent(input: ConsentInput): Promise<void>;
/**
* Alle Kategorien akzeptieren
*/
acceptAll(): Promise<void>;
/**
* Alle nicht-essentiellen Kategorien ablehnen
*/
rejectAll(): Promise<void>;
/**
* Alle Einwilligungen widerrufen
*/
revokeAll(): Promise<void>;
/**
* Consent-Daten exportieren (DSGVO Art. 20)
*/
exportConsent(): Promise<string>;
/**
* Pruefen ob Consent-Abfrage noetig
*/
needsConsent(): boolean;
/**
* Banner anzeigen
*/
showBanner(): void;
/**
* Banner verstecken
*/
hideBanner(): void;
/**
* Einstellungs-Modal oeffnen
*/
showSettings(): void;
/**
* Pruefen ob Banner sichtbar
*/
isBannerVisible(): boolean;
/**
* Event-Listener registrieren
*/
on<T extends ConsentEventType>(event: T, callback: ConsentEventCallback<ConsentEventData[T]>): () => void;
/**
* Event-Listener entfernen
*/
off<T extends ConsentEventType>(event: T, callback: ConsentEventCallback<ConsentEventData[T]>): void;
/**
* Konfiguration zusammenfuehren
*/
private mergeConfig;
/**
* Consent-Input normalisieren
*/
private normalizeConsentInput;
/**
* Consent anwenden (Skripte aktivieren/blockieren)
*/
private applyConsent;
/**
* Google Consent Mode v2 aktualisieren
*/
private updateGoogleConsentMode;
/**
* Pruefen ob Consent abgelaufen
*/
private isConsentExpired;
/**
* Event emittieren
*/
private emit;
/**
* Fehler behandeln
*/
private handleError;
/**
* Debug-Logging
*/
private log;
/**
* SDK-Version abrufen
*/
static getVersion(): string;
}
interface ConsentContextValue {
/** ConsentManager Instanz */
manager: ConsentManager | null;
/** Aktueller Consent-State */
consent: ConsentState | null;
/** Ist SDK initialisiert? */
isInitialized: boolean;
/** Wird geladen? */
isLoading: boolean;
/** Ist Banner sichtbar? */
isBannerVisible: boolean;
/** Wird Consent benoetigt? */
needsConsent: boolean;
/** Consent fuer Kategorie pruefen */
hasConsent: (category: ConsentCategory) => boolean;
/** Alle akzeptieren */
acceptAll: () => Promise<void>;
/** Alle ablehnen */
rejectAll: () => Promise<void>;
/** Auswahl speichern */
saveSelection: (categories: Partial<ConsentCategories>) => Promise<void>;
/** Banner anzeigen */
showBanner: () => void;
/** Banner verstecken */
hideBanner: () => void;
/** Einstellungen oeffnen */
showSettings: () => void;
}
declare const ConsentContext: react.Context<ConsentContextValue | null>;
interface ConsentProviderProps {
/** SDK-Konfiguration */
config: ConsentConfig;
/** Kinder-Komponenten */
children: ReactNode;
}
/**
* ConsentProvider - Stellt Consent-Kontext bereit
*/
declare const ConsentProvider: FC<ConsentProviderProps>;
/**
* useConsent - Hook fuer Consent-Zugriff
*
* @example
* ```tsx
* const { hasConsent, acceptAll, rejectAll } = useConsent();
*
* if (hasConsent('analytics')) {
* // Analytics laden
* }
* ```
*/
declare function useConsent(): ConsentContextValue;
declare function useConsent(category: ConsentCategory): ConsentContextValue & {
allowed: boolean;
};
/**
* useConsentManager - Direkter Zugriff auf ConsentManager
*/
declare function useConsentManager(): ConsentManager | null;
interface ConsentGateProps {
/** Erforderliche Kategorie */
category: ConsentCategory;
/** Inhalt bei Consent */
children: ReactNode;
/** Inhalt ohne Consent */
placeholder?: ReactNode;
/** Fallback waehrend Laden */
fallback?: ReactNode;
}
/**
* ConsentGate - Zeigt Inhalt nur bei Consent
*
* @example
* ```tsx
* <ConsentGate
* category="analytics"
* placeholder={<ConsentPlaceholder category="analytics" />}
* >
* <GoogleAnalytics />
* </ConsentGate>
* ```
*/
declare const ConsentGate: FC<ConsentGateProps>;
interface ConsentPlaceholderProps {
/** Kategorie */
category: ConsentCategory;
/** Custom Nachricht */
message?: string;
/** Custom Button-Text */
buttonText?: string;
/** Custom Styling */
className?: string;
}
/**
* ConsentPlaceholder - Placeholder fuer blockierten Inhalt
*/
declare const ConsentPlaceholder: FC<ConsentPlaceholderProps>;
interface ConsentBannerRenderProps {
/** Ist Banner sichtbar? */
isVisible: boolean;
/** Aktueller Consent */
consent: ConsentState | null;
/** Wird Consent benoetigt? */
needsConsent: boolean;
/** Alle akzeptieren */
onAcceptAll: () => void;
/** Alle ablehnen */
onRejectAll: () => void;
/** Auswahl speichern */
onSaveSelection: (categories: Partial<ConsentCategories>) => void;
/** Einstellungen oeffnen */
onShowSettings: () => void;
/** Banner schliessen */
onClose: () => void;
}
interface ConsentBannerProps {
/** Render-Funktion fuer Custom UI */
render?: (props: ConsentBannerRenderProps) => ReactNode;
/** Custom Styling */
className?: string;
}
/**
* ConsentBanner - Headless Banner-Komponente
*
* Kann mit eigener UI gerendert werden oder nutzt Default-UI.
*
* @example
* ```tsx
* // Mit eigener UI
* <ConsentBanner
* render={({ isVisible, onAcceptAll, onRejectAll }) => (
* isVisible && (
* <div className="my-banner">
* <button onClick={onAcceptAll}>Accept</button>
* <button onClick={onRejectAll}>Reject</button>
* </div>
* )
* )}
* />
*
* // Mit Default-UI
* <ConsentBanner />
* ```
*/
declare const ConsentBanner: FC<ConsentBannerProps>;
export { ConsentBanner, type ConsentBannerRenderProps, ConsentContext, type ConsentContextValue, ConsentGate, ConsentPlaceholder, ConsentProvider, useConsent, useConsentManager };