UNPKG

astro-iubenda

Version:

Astro integration for Iubenda Privacy Policy and Terms & Conditions

174 lines (169 loc) 6.6 kB
/// <reference path="./virtual.d.ts" /> import { AstroIntegration } from 'astro'; type HexColor = `#${string}`; type BannerVersion = "beta" | "current" | "stable"; type TcfPurposesKeys = "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10"; type ConsentEventName = "documentScroll" | "documentMoved" | "bannerXClose" | "documentClicked" | "cookiePolicyClosed"; interface IubendaCallbacks { onReady?: (has: boolean) => void; onBannerShown?: () => void; onBannerClosed?: () => void; onCookiePolicyShown?: () => void; onConsentGiven?: (c: boolean) => void; onConsentFirstGiven?: (e: ConsentEventName) => void; onConsentRejected?: () => void; onConsentFirstRejected?: (e: ConsentEventName) => void; onPreferenceExpressed?: (p: unknown) => void; onPreferenceFirstExpressed?: (p: unknown) => void; onPreferenceExpressedOrNotNeeded?: (p: unknown) => void; onPreferenceNotNeeded?: () => void; onConsentRead?: (c: boolean) => void; onStartupFailed?: (msg: string) => void; onError?: (msg: string) => void; onFatalError?: (msg: string) => void; onActivationDone?: () => void; onBeforePreload?: () => void; onCcpaAcknowledged?: () => void; onCcpaFirstAcknowledged?: () => void; onCcpaOptOut?: () => void; onCcpaFirstOptOut?: () => void; on2ndLayerShown?: () => void; } interface IubendaOptions { siteId: number; cookiePolicyId: number; lang: string; countryDetection?: boolean; enableGdpr?: boolean; gdprAppliesGlobally?: boolean; gdprApplies?: boolean; perPurposeConsent?: boolean; purposes?: string; enableUspr?: boolean; usprApplies?: boolean; usprPurposes?: string; showBannerForUS?: boolean; noticeAtCollectionUrl?: string; enableCcpa?: boolean; ccpaApplies?: boolean; ccpaNoticeDisplay?: boolean; ccpaAcknowledgeOnDisplay?: boolean; ccpaAcknowledgeOnLoad?: boolean; ccpaLspa?: boolean; enableLgpd?: boolean; lgpdAppliesGlobally?: boolean; lgpdApplies?: boolean; enableTcf?: boolean; googleAdditionalConsentMode?: boolean; tcfPurposes?: { [K in TcfPurposesKeys]?: "consent_not_needed" | false | "li_only" | "consent_only"; }; askConsentIfCMPNotFound?: boolean; newConsentAtVendorListUpdate?: number; tcfPublisherCC?: string; acceptTcfSpecialFeaturesWithAcceptBtn?: boolean; banner?: { acceptButtonDisplay?: boolean; customizeButtonDisplay?: boolean; rejectButtonDisplay?: boolean; closeButtonDisplay?: boolean; closeButtonRejects?: boolean; explicitWithdrawal?: boolean; listPurposes?: boolean; showPurposesToggles?: boolean; position?: "top" | "bottom" | "float-top-left" | "float-top-right" | "float-bottom-left" | "float-bottom-right" | "float-top-center" | "float-bottom-center" | "float-center"; backgroundOverlay?: boolean; logo?: string; brandTextColor?: HexColor; brandBackgroundColor?: HexColor; backgroundColor?: HexColor; textColor?: HexColor; acceptButtonColor?: HexColor; acceptButtonCaptionColor?: HexColor; customizeButtonColor?: HexColor; customizeButtonCaptionColor?: HexColor; rejectButtonColor?: HexColor; rejectButtonCaptionColor?: HexColor; continueWithoutAcceptingButtonColor?: HexColor; continueWithoutAcceptingButtonCaptionColor?: HexColor; applyStyles?: boolean; zIndex?: number; fontSize?: string; fontSizeCloseButton?: string; fontSizeBody?: string; content?: string; acceptButtonCaption?: string; customizeButtonCaption?: string; rejectButtonCaption?: string; closeButtonCaption?: string; continueWithoutAcceptingButtonCaption?: string | false; useThirdParties?: boolean; showTotalNumberOfProviders?: boolean; totalNumberOfProviders?: number; html?: string; footer?: { btnCaption?: string; }; i18n?: Record<string, unknown>; cookiePolicyLinkCaption?: string; slideDown?: boolean; prependOnBody?: boolean; }; floatingPreferencesButtonDisplay?: boolean | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "anchored-center-left" | "anchored-center-right" | "anchored-top-left" | "anchored-top-right" | "anchored-bottom-left" | "anchored-bottom-right"; floatingPreferencesButtonCaption?: string; floatingPreferencesButtonIcon?: boolean; floatingPreferencesButtonHover?: boolean; floatingPreferencesButtonRound?: boolean; floatingPreferencesButtonZIndex?: number; floatingPreferencesButtonColor?: HexColor; floatingPreferencesButtonCaptionColor?: HexColor; privacyPolicyUrl?: string; cookiePolicyUrl?: string; cookiePolicyInOtherWindow?: boolean; cookiePolicyLinkCaption?: string; reloadOnConsent?: boolean; askConsentAtCookiePolicyUpdate?: boolean; enableRemoteConsent?: boolean; invalidateConsentWithoutLog?: boolean | `${number}-${number}-${number}`; googleConsentMode?: boolean | "template"; inlineDelay?: number; rebuildIframe?: boolean; skipSaveConsent?: boolean; logLevel?: "debug" | "info" | "warn" | "error" | "fatal" | "nolog"; safeTimeout?: number; forceSafeActivation?: boolean; preferenceCookie?: { expireAfter?: number; }; ccpaCookie?: { expireAfter?: number; }; localConsentDomain?: string; localConsentDomainExact?: boolean; localConsentPath?: string; whitelabel?: boolean; invalidateConsentBefore?: number | `${number}-${number}-${number}`; maxCookieSize?: number; maxCookieChunks?: number; timeoutLoadConfiguration?: number; startOnDomReady?: boolean; callback?: IubendaCallbacks; } interface CookieFooterOptions { iubendaOptions: IubendaOptions; googleTagManagerOptions?: boolean | { eventName?: string; dataLayerName?: string; }; injectionStage?: "head-inline" | "page"; bannerVersion?: BannerVersion; } interface Options { documentIds: Array<number | string>; saveInJson?: boolean; outputDir?: string; stripMarkup?: boolean; cookieFooter?: false | CookieFooterOptions; } declare function iubenda(opts: Options): AstroIntegration; export { type BannerVersion, type ConsentEventName, type CookieFooterOptions, type HexColor, type IubendaCallbacks, type IubendaOptions, type Options, type TcfPurposesKeys, iubenda as default };