UNPKG

acronweb-cookies

Version:

A modern, GDPR-compliant cookie consent plugin for React and Next.js applications

140 lines (132 loc) 4.73 kB
import * as react_jsx_runtime from 'react/jsx-runtime'; import { FirebaseApp } from 'firebase/app'; import { Firestore } from 'firebase/firestore'; interface CookieConsentProps { language?: 'el' | 'en'; firebaseConfig?: FirebaseConfig; onAccept?: (consent: boolean) => void; onDecline?: () => void; customContent?: { el?: Partial<ContentType>; en?: Partial<ContentType>; }; privacyUrl?: string; showPoweredBy?: boolean; theme?: 'light' | 'dark' | 'auto'; position?: 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right' | 'center'; autoHide?: boolean; autoHideDelay?: number; } interface ContentType { title: string; description: string; accept: string; learnMore: string; decline: string; } interface FirebaseConfig { apiKey: string; authDomain: string; projectId: string; storageBucket: string; messagingSenderId: string; appId: string; } interface UserConsent { id: string; consent: boolean; timestamp: Date; language: string; userAgent: string; ipAddress?: string; country?: string; city?: string; } interface CookieSettings { necessary: boolean; analytics: boolean; marketing: boolean; preferences: boolean; } interface CookieConsentState { isVisible: boolean; isLoaded: boolean; isMobile: boolean; consent: boolean | null; settings: CookieSettings; } interface CookieManager { setConsent: (consent: boolean, settings?: Partial<CookieSettings>) => void; getConsent: () => boolean | null; clearConsent: () => void; setCookie: (name: string, value: string, options?: any) => void; getCookie: (name: string) => string | undefined; removeCookie: (name: string) => void; saveToFirebase: (consent: UserConsent) => Promise<void>; } interface FirebaseService { initialize: (config: FirebaseConfig) => void; saveConsent: (consent: UserConsent) => Promise<void>; getConsent: (userId: string) => Promise<UserConsent | null>; } declare function CookieConsent({ language, firebaseConfig, onAccept, onDecline, customContent, privacyUrl, showPoweredBy, theme, position, autoHide, autoHideDelay }: CookieConsentProps): react_jsx_runtime.JSX.Element | null; interface CookieSettingsButtonProps { language?: string; } declare function CookieSettingsButton({ language }: CookieSettingsButtonProps): react_jsx_runtime.JSX.Element; declare class AcronWebCookieManager implements CookieManager { private readonly CONSENT_KEY; private readonly SETTINGS_KEY; private readonly USER_ID_KEY; setConsent(consent: boolean, settings?: Partial<CookieSettings>): void; getConsent(): boolean | null; clearConsent(): void; setCookie(name: string, value: string, options?: any): void; getCookie(name: string): string | undefined; removeCookie(name: string): void; getSettings(): CookieSettings | null; getUserId(): string; private generateUserId; private ensureUserId; saveToFirebase(consent: UserConsent): Promise<void>; } declare const cookieManager: AcronWebCookieManager; declare class AcronWebFirebaseService implements FirebaseService { private app; private db; private isInitialized; initialize(config: FirebaseConfig): void; saveConsent(consent: UserConsent): Promise<void>; getConsent(userId: string): Promise<UserConsent | null>; getConsentStats(): Promise<{ total: number; accepted: number; declined: number; byLanguage: Record<string, number>; }>; getUserLocation(): Promise<{ country?: string; city?: string; ipAddress?: string; }>; isReady(): boolean; getApp(): FirebaseApp | null; getDb(): Firestore | null; } declare const firebaseService: AcronWebFirebaseService; declare const openCookieConsent: () => void; declare const clearCookieConsent: () => void; declare const getCookieConsent: () => any; declare const setCookieConsent: (consent: boolean, settings?: any) => void; declare const _default: { CookieConsent: any; CookieSettingsButton: any; cookieManager: any; firebaseService: any; openCookieConsent: () => void; clearCookieConsent: () => void; getCookieConsent: () => any; setCookieConsent: (consent: boolean, settings?: any) => void; }; export { AcronWebCookieManager, AcronWebFirebaseService, CookieConsent, CookieSettingsButton, clearCookieConsent, cookieManager, _default as default, firebaseService, getCookieConsent, openCookieConsent, setCookieConsent }; export type { ContentType, CookieConsentProps, CookieConsentState, CookieManager, CookieSettings, FirebaseConfig, FirebaseService, UserConsent };