Comparing version 0.0.1-rc.9 to 0.0.1-rc.10
@@ -7,22 +7,4 @@ export { createConsentManagerStore } from './store'; | ||
export { consentTypes } from './types'; | ||
export type { | ||
CallbackFunction, | ||
Callbacks, | ||
AllConsentNames, | ||
ConsentType, | ||
ConsentState, | ||
ComplianceRegion, | ||
ComplianceSettings, | ||
PrivacySettings, | ||
HasConsentedProps, | ||
NamespaceProps, | ||
TranslationConfig, | ||
Translations, | ||
CookieBannerTranslations, | ||
ConsentManagerDialogTranslations, | ||
ConsentManagerWidgetTranslations, | ||
ConsentTypeTranslations, | ||
ConsentTypesTranslations, | ||
} from './types'; | ||
export type { CallbackFunction, Callbacks, AllConsentNames, ConsentType, ConsentState, ComplianceRegion, ComplianceSettings, PrivacySettings, HasConsentedProps, NamespaceProps, TranslationConfig, Translations, CookieBannerTranslations, ConsentManagerDialogTranslations, ConsentManagerWidgetTranslations, ConsentTypeTranslations, ConsentTypesTranslations, LocationInfo, JurisdictionInfo, ConsentBannerResponse, } from './types'; | ||
export { defaultTranslationConfig } from './translations'; | ||
//# sourceMappingURL=index.d.ts.map | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,19 +0,10 @@ | ||
import * as __WEBPACK_EXTERNAL_MODULE__store_js_535ade31__ from './store.js'; | ||
import * as __WEBPACK_EXTERNAL_MODULE__libs_tracking_blocker_js_b46fe1fa__ from './libs/tracking-blocker.js'; | ||
import * as __WEBPACK_EXTERNAL_MODULE__types_index_js_63ede62f__ from './types/index.js'; | ||
import * as __WEBPACK_EXTERNAL_MODULE__translations_index_js_8dbce45e__ from './translations/index.js'; | ||
export * from './libs/consent-utils.js'; | ||
var __webpack_exports__consentTypes = | ||
__WEBPACK_EXTERNAL_MODULE__types_index_js_63ede62f__.consentTypes; | ||
var __webpack_exports__createConsentManagerStore = | ||
__WEBPACK_EXTERNAL_MODULE__store_js_535ade31__.createConsentManagerStore; | ||
var __webpack_exports__createTrackingBlocker = | ||
__WEBPACK_EXTERNAL_MODULE__libs_tracking_blocker_js_b46fe1fa__.createTrackingBlocker; | ||
var __webpack_exports__defaultTranslationConfig = | ||
__WEBPACK_EXTERNAL_MODULE__translations_index_js_8dbce45e__.defaultTranslationConfig; | ||
export { | ||
__webpack_exports__consentTypes as consentTypes, | ||
__webpack_exports__createConsentManagerStore as createConsentManagerStore, | ||
__webpack_exports__createTrackingBlocker as createTrackingBlocker, | ||
__webpack_exports__defaultTranslationConfig as defaultTranslationConfig, | ||
}; | ||
import * as __WEBPACK_EXTERNAL_MODULE__store_js_535ade31__ from "./store.js"; | ||
import * as __WEBPACK_EXTERNAL_MODULE__libs_tracking_blocker_js_b46fe1fa__ from "./libs/tracking-blocker.js"; | ||
import * as __WEBPACK_EXTERNAL_MODULE__types_index_js_63ede62f__ from "./types/index.js"; | ||
import * as __WEBPACK_EXTERNAL_MODULE__translations_index_js_8dbce45e__ from "./translations/index.js"; | ||
export * from "./libs/consent-utils.js"; | ||
var __webpack_exports__consentTypes = __WEBPACK_EXTERNAL_MODULE__types_index_js_63ede62f__.consentTypes; | ||
var __webpack_exports__createConsentManagerStore = __WEBPACK_EXTERNAL_MODULE__store_js_535ade31__.createConsentManagerStore; | ||
var __webpack_exports__createTrackingBlocker = __WEBPACK_EXTERNAL_MODULE__libs_tracking_blocker_js_b46fe1fa__.createTrackingBlocker; | ||
var __webpack_exports__defaultTranslationConfig = __WEBPACK_EXTERNAL_MODULE__translations_index_js_8dbce45e__.defaultTranslationConfig; | ||
export { __webpack_exports__consentTypes as consentTypes, __webpack_exports__createConsentManagerStore as createConsentManagerStore, __webpack_exports__createTrackingBlocker as createTrackingBlocker, __webpack_exports__defaultTranslationConfig as defaultTranslationConfig }; |
export {}; | ||
//# sourceMappingURL=tracking-blocker.test.d.ts.map | ||
//# sourceMappingURL=tracking-blocker.test.d.ts.map |
@@ -1,267 +0,143 @@ | ||
import * as __WEBPACK_EXTERNAL_MODULE_vitest__ from 'vitest'; | ||
import * as __WEBPACK_EXTERNAL_MODULE__tracking_blocker_js_d038b07a__ from '../tracking-blocker.js'; | ||
import * as __WEBPACK_EXTERNAL_MODULE_vitest__ from "vitest"; | ||
import * as __WEBPACK_EXTERNAL_MODULE__tracking_blocker_js_d038b07a__ from "../tracking-blocker.js"; | ||
var __webpack_require__ = {}; | ||
(() => { | ||
__webpack_require__.g = (function () { | ||
if ('object' == typeof globalThis) return globalThis; | ||
try { | ||
return this || new Function('return this')(); | ||
} catch (e) { | ||
if ('object' == typeof window) return window; | ||
} | ||
})(); | ||
(()=>{ | ||
__webpack_require__.g = function() { | ||
if ('object' == typeof globalThis) return globalThis; | ||
try { | ||
return this || new Function('return this')(); | ||
} catch (e) { | ||
if ('object' == typeof window) return window; | ||
} | ||
}(); | ||
})(); | ||
const BLOCKED_CONSENT = { | ||
experience: false, | ||
functionality: false, | ||
marketing: false, | ||
measurement: false, | ||
necessary: true, | ||
experience: false, | ||
functionality: false, | ||
marketing: false, | ||
measurement: false, | ||
necessary: true | ||
}; | ||
const ALLOWED_CONSENT = { | ||
...BLOCKED_CONSENT, | ||
measurement: true, | ||
...BLOCKED_CONSENT, | ||
measurement: true | ||
}; | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.describe)('TrackingBlocker', () => { | ||
const originalFetch = __webpack_require__.g.fetch; | ||
const originalXHR = __webpack_require__.g.XMLHttpRequest; | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.beforeAll)(() => { | ||
__webpack_require__.g.fetch = __WEBPACK_EXTERNAL_MODULE_vitest__.vi | ||
.fn() | ||
.mockImplementation(() => Promise.resolve(new Response())); | ||
if (!__webpack_require__.g.XMLHttpRequest) | ||
__webpack_require__.g.XMLHttpRequest = originalXHR; | ||
}); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.afterAll)(() => { | ||
__webpack_require__.g.fetch = originalFetch; | ||
__webpack_require__.g.XMLHttpRequest = originalXHR; | ||
}); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.beforeEach)(() => { | ||
__WEBPACK_EXTERNAL_MODULE_vitest__.vi.clearAllMocks(); | ||
__WEBPACK_EXTERNAL_MODULE_vitest__.vi.restoreAllMocks(); | ||
__webpack_require__.g.fetch = __WEBPACK_EXTERNAL_MODULE_vitest__.vi | ||
.fn() | ||
.mockImplementation(() => Promise.resolve(new Response())); | ||
window.fetch = __webpack_require__.g.fetch; | ||
window.XMLHttpRequest = originalXHR; | ||
__WEBPACK_EXTERNAL_MODULE_vitest__.vi.spyOn(document, 'dispatchEvent'); | ||
}); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)( | ||
'blocks fetch requests to tracking domains when consent not granted', | ||
async () => { | ||
(0, | ||
__WEBPACK_EXTERNAL_MODULE__tracking_blocker_js_d038b07a__.createTrackingBlocker)( | ||
{}, | ||
BLOCKED_CONSENT | ||
); | ||
await (0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)( | ||
fetch('https://www.google-analytics.com/analytics.js') | ||
).rejects.toThrow( | ||
'Request to https://www.google-analytics.com/analytics.js blocked due to missing consent' | ||
); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)( | ||
document.dispatchEvent | ||
).toHaveBeenCalledWith( | ||
__WEBPACK_EXTERNAL_MODULE_vitest__.expect.objectContaining({ | ||
type: 'ConsentBlockedRequest', | ||
detail: { | ||
url: 'https://www.google-analytics.com/analytics.js', | ||
}, | ||
}) | ||
); | ||
} | ||
); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)( | ||
'blocks XMLHttpRequest to tracking domains when consent not granted', | ||
() => { | ||
(0, | ||
__WEBPACK_EXTERNAL_MODULE__tracking_blocker_js_d038b07a__.createTrackingBlocker)( | ||
{}, | ||
BLOCKED_CONSENT | ||
); | ||
const xhr = new XMLHttpRequest(); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)(() => { | ||
xhr.open('GET', 'https://www.google-analytics.com/analytics.js'); | ||
}).toThrow( | ||
'Request to https://www.google-analytics.com/analytics.js blocked due to missing consent' | ||
); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)( | ||
document.dispatchEvent | ||
).toHaveBeenCalledWith( | ||
__WEBPACK_EXTERNAL_MODULE_vitest__.expect.objectContaining({ | ||
type: 'ConsentBlockedRequest', | ||
detail: { | ||
url: 'https://www.google-analytics.com/analytics.js', | ||
}, | ||
}) | ||
); | ||
} | ||
); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)( | ||
'allows fetch requests to tracking domains after consent granted', | ||
async () => { | ||
window.fetch = __webpack_require__.g.fetch; | ||
const trackingBlocker = (0, | ||
__WEBPACK_EXTERNAL_MODULE__tracking_blocker_js_d038b07a__.createTrackingBlocker)( | ||
{}, | ||
ALLOWED_CONSENT | ||
); | ||
const fetchSpy = __WEBPACK_EXTERNAL_MODULE_vitest__.vi.spyOn( | ||
window, | ||
'fetch' | ||
); | ||
await fetch('https://www.google-analytics.com/analytics.js'); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)( | ||
fetchSpy | ||
).toHaveBeenCalledWith('https://www.google-analytics.com/analytics.js'); | ||
trackingBlocker.destroy(); | ||
} | ||
); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)( | ||
'allows XMLHttpRequest to tracking domains after consent granted', | ||
() => { | ||
(0, | ||
__WEBPACK_EXTERNAL_MODULE__tracking_blocker_js_d038b07a__.createTrackingBlocker)( | ||
{}, | ||
ALLOWED_CONSENT | ||
); | ||
const xhr = new XMLHttpRequest(); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)(() => { | ||
xhr.open('GET', 'https://www.google-analytics.com/analytics.js'); | ||
}).not.toThrow(); | ||
} | ||
); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)( | ||
'allows requests to non-tracking domains regardless of consent', | ||
async () => { | ||
(0, | ||
__WEBPACK_EXTERNAL_MODULE__tracking_blocker_js_d038b07a__.createTrackingBlocker)( | ||
{}, | ||
BLOCKED_CONSENT | ||
); | ||
const fetchSpy = __WEBPACK_EXTERNAL_MODULE_vitest__.vi.spyOn( | ||
window, | ||
'fetch' | ||
); | ||
await fetch('https://api.example.com/data'); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)( | ||
fetchSpy | ||
).toHaveBeenCalledWith('https://api.example.com/data'); | ||
const xhr = new XMLHttpRequest(); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)(() => { | ||
xhr.open('GET', 'https://api.example.com/data'); | ||
}).not.toThrow(); | ||
} | ||
); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)( | ||
'handles custom domain consent map', | ||
async () => { | ||
const trackingBlocker = (0, | ||
__WEBPACK_EXTERNAL_MODULE__tracking_blocker_js_d038b07a__.createTrackingBlocker)( | ||
{ | ||
overrideDomainConsentMap: true, | ||
domainConsentMap: { | ||
'custom-analytics.example.com': 'measurement', | ||
}, | ||
}, | ||
BLOCKED_CONSENT | ||
); | ||
await (0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)( | ||
fetch('https://custom-analytics.example.com/track') | ||
).rejects.toThrow( | ||
'Request to https://custom-analytics.example.com/track blocked due to missing consent' | ||
); | ||
trackingBlocker.updateConsents({ | ||
experience: false, | ||
functionality: false, | ||
marketing: false, | ||
measurement: true, | ||
necessary: true, | ||
}); | ||
const fetchSpy = __WEBPACK_EXTERNAL_MODULE_vitest__.vi.spyOn( | ||
window, | ||
'fetch' | ||
); | ||
await fetch('https://custom-analytics.example.com/track'); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)( | ||
fetchSpy | ||
).toHaveBeenCalledWith('https://custom-analytics.example.com/track'); | ||
} | ||
); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)( | ||
'handles subdomains correctly', | ||
async () => { | ||
(0, | ||
__WEBPACK_EXTERNAL_MODULE__tracking_blocker_js_d038b07a__.createTrackingBlocker)( | ||
{}, | ||
BLOCKED_CONSENT | ||
); | ||
await (0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)( | ||
fetch('https://subdomain.google-analytics.com/track') | ||
).rejects.toThrow( | ||
'Request to https://subdomain.google-analytics.com/track blocked due to missing consent' | ||
); | ||
} | ||
); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)( | ||
'can be disabled via config', | ||
async () => { | ||
(0, | ||
__WEBPACK_EXTERNAL_MODULE__tracking_blocker_js_d038b07a__.createTrackingBlocker)( | ||
{ | ||
disableAutomaticBlocking: true, | ||
}, | ||
BLOCKED_CONSENT | ||
); | ||
await fetch('https://www.google-analytics.com/analytics.js'); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)( | ||
fetch | ||
).toHaveBeenCalledWith('https://www.google-analytics.com/analytics.js'); | ||
} | ||
); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)( | ||
'cleanup restores original fetch and XMLHttpRequest functionality', | ||
async () => { | ||
const trackingBlocker = (0, | ||
__WEBPACK_EXTERNAL_MODULE__tracking_blocker_js_d038b07a__.createTrackingBlocker)( | ||
{}, | ||
BLOCKED_CONSENT | ||
); | ||
await (0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)( | ||
fetch('https://www.google-analytics.com/analytics.js') | ||
).rejects.toThrow(); | ||
trackingBlocker.destroy(); | ||
await fetch('https://www.google-analytics.com/analytics.js'); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)( | ||
fetch | ||
).toHaveBeenCalledWith('https://www.google-analytics.com/analytics.js'); | ||
const xhr = new XMLHttpRequest(); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)(() => { | ||
xhr.open('GET', 'https://www.google-analytics.com/analytics.js'); | ||
}).not.toThrow(); | ||
} | ||
); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)( | ||
'handles multiple concurrent requests correctly', | ||
async () => { | ||
(0, | ||
__WEBPACK_EXTERNAL_MODULE__tracking_blocker_js_d038b07a__.createTrackingBlocker)( | ||
{}, | ||
BLOCKED_CONSENT | ||
); | ||
const requests = Promise.all([ | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)( | ||
fetch('https://www.google-analytics.com/analytics.js') | ||
).rejects.toThrow(), | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)( | ||
fetch('https://www.google-analytics.com/collect') | ||
).rejects.toThrow(), | ||
fetch('https://api.example.com/data'), | ||
]); | ||
await requests; | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)( | ||
document.dispatchEvent | ||
).toHaveBeenCalledTimes(6); | ||
} | ||
); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.describe)('TrackingBlocker', ()=>{ | ||
const originalFetch = __webpack_require__.g.fetch; | ||
const originalXHR = __webpack_require__.g.XMLHttpRequest; | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.beforeAll)(()=>{ | ||
__webpack_require__.g.fetch = __WEBPACK_EXTERNAL_MODULE_vitest__.vi.fn().mockImplementation(()=>Promise.resolve(new Response())); | ||
if (!__webpack_require__.g.XMLHttpRequest) __webpack_require__.g.XMLHttpRequest = originalXHR; | ||
}); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.afterAll)(()=>{ | ||
__webpack_require__.g.fetch = originalFetch; | ||
__webpack_require__.g.XMLHttpRequest = originalXHR; | ||
}); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.beforeEach)(()=>{ | ||
__WEBPACK_EXTERNAL_MODULE_vitest__.vi.clearAllMocks(); | ||
__WEBPACK_EXTERNAL_MODULE_vitest__.vi.restoreAllMocks(); | ||
__webpack_require__.g.fetch = __WEBPACK_EXTERNAL_MODULE_vitest__.vi.fn().mockImplementation(()=>Promise.resolve(new Response())); | ||
window.fetch = __webpack_require__.g.fetch; | ||
window.XMLHttpRequest = originalXHR; | ||
__WEBPACK_EXTERNAL_MODULE_vitest__.vi.spyOn(document, 'dispatchEvent'); | ||
}); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)('blocks fetch requests to tracking domains when consent not granted', async ()=>{ | ||
(0, __WEBPACK_EXTERNAL_MODULE__tracking_blocker_js_d038b07a__.createTrackingBlocker)({}, BLOCKED_CONSENT); | ||
await (0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)(fetch('https://www.google-analytics.com/analytics.js')).rejects.toThrow('Request to https://www.google-analytics.com/analytics.js blocked due to missing consent'); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)(document.dispatchEvent).toHaveBeenCalledWith(__WEBPACK_EXTERNAL_MODULE_vitest__.expect.objectContaining({ | ||
type: 'ConsentBlockedRequest', | ||
detail: { | ||
url: 'https://www.google-analytics.com/analytics.js' | ||
} | ||
})); | ||
}); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)('blocks XMLHttpRequest to tracking domains when consent not granted', ()=>{ | ||
(0, __WEBPACK_EXTERNAL_MODULE__tracking_blocker_js_d038b07a__.createTrackingBlocker)({}, BLOCKED_CONSENT); | ||
const xhr = new XMLHttpRequest(); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)(()=>{ | ||
xhr.open('GET', 'https://www.google-analytics.com/analytics.js'); | ||
}).toThrow('Request to https://www.google-analytics.com/analytics.js blocked due to missing consent'); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)(document.dispatchEvent).toHaveBeenCalledWith(__WEBPACK_EXTERNAL_MODULE_vitest__.expect.objectContaining({ | ||
type: 'ConsentBlockedRequest', | ||
detail: { | ||
url: 'https://www.google-analytics.com/analytics.js' | ||
} | ||
})); | ||
}); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)('allows fetch requests to tracking domains after consent granted', async ()=>{ | ||
window.fetch = __webpack_require__.g.fetch; | ||
const trackingBlocker = (0, __WEBPACK_EXTERNAL_MODULE__tracking_blocker_js_d038b07a__.createTrackingBlocker)({}, ALLOWED_CONSENT); | ||
const fetchSpy = __WEBPACK_EXTERNAL_MODULE_vitest__.vi.spyOn(window, 'fetch'); | ||
await fetch('https://www.google-analytics.com/analytics.js'); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)(fetchSpy).toHaveBeenCalledWith('https://www.google-analytics.com/analytics.js'); | ||
trackingBlocker.destroy(); | ||
}); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)('allows XMLHttpRequest to tracking domains after consent granted', ()=>{ | ||
(0, __WEBPACK_EXTERNAL_MODULE__tracking_blocker_js_d038b07a__.createTrackingBlocker)({}, ALLOWED_CONSENT); | ||
const xhr = new XMLHttpRequest(); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)(()=>{ | ||
xhr.open('GET', 'https://www.google-analytics.com/analytics.js'); | ||
}).not.toThrow(); | ||
}); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)('allows requests to non-tracking domains regardless of consent', async ()=>{ | ||
(0, __WEBPACK_EXTERNAL_MODULE__tracking_blocker_js_d038b07a__.createTrackingBlocker)({}, BLOCKED_CONSENT); | ||
const fetchSpy = __WEBPACK_EXTERNAL_MODULE_vitest__.vi.spyOn(window, 'fetch'); | ||
await fetch('https://api.example.com/data'); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)(fetchSpy).toHaveBeenCalledWith('https://api.example.com/data'); | ||
const xhr = new XMLHttpRequest(); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)(()=>{ | ||
xhr.open('GET', 'https://api.example.com/data'); | ||
}).not.toThrow(); | ||
}); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)('handles custom domain consent map', async ()=>{ | ||
const trackingBlocker = (0, __WEBPACK_EXTERNAL_MODULE__tracking_blocker_js_d038b07a__.createTrackingBlocker)({ | ||
overrideDomainConsentMap: true, | ||
domainConsentMap: { | ||
'custom-analytics.example.com': 'measurement' | ||
} | ||
}, BLOCKED_CONSENT); | ||
await (0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)(fetch('https://custom-analytics.example.com/track')).rejects.toThrow('Request to https://custom-analytics.example.com/track blocked due to missing consent'); | ||
trackingBlocker.updateConsents({ | ||
experience: false, | ||
functionality: false, | ||
marketing: false, | ||
measurement: true, | ||
necessary: true | ||
}); | ||
const fetchSpy = __WEBPACK_EXTERNAL_MODULE_vitest__.vi.spyOn(window, 'fetch'); | ||
await fetch('https://custom-analytics.example.com/track'); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)(fetchSpy).toHaveBeenCalledWith('https://custom-analytics.example.com/track'); | ||
}); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)('handles subdomains correctly', async ()=>{ | ||
(0, __WEBPACK_EXTERNAL_MODULE__tracking_blocker_js_d038b07a__.createTrackingBlocker)({}, BLOCKED_CONSENT); | ||
await (0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)(fetch('https://subdomain.google-analytics.com/track')).rejects.toThrow('Request to https://subdomain.google-analytics.com/track blocked due to missing consent'); | ||
}); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)('can be disabled via config', async ()=>{ | ||
(0, __WEBPACK_EXTERNAL_MODULE__tracking_blocker_js_d038b07a__.createTrackingBlocker)({ | ||
disableAutomaticBlocking: true | ||
}, BLOCKED_CONSENT); | ||
await fetch('https://www.google-analytics.com/analytics.js'); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)(fetch).toHaveBeenCalledWith('https://www.google-analytics.com/analytics.js'); | ||
}); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)('cleanup restores original fetch and XMLHttpRequest functionality', async ()=>{ | ||
const trackingBlocker = (0, __WEBPACK_EXTERNAL_MODULE__tracking_blocker_js_d038b07a__.createTrackingBlocker)({}, BLOCKED_CONSENT); | ||
await (0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)(fetch('https://www.google-analytics.com/analytics.js')).rejects.toThrow(); | ||
trackingBlocker.destroy(); | ||
await fetch('https://www.google-analytics.com/analytics.js'); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)(fetch).toHaveBeenCalledWith('https://www.google-analytics.com/analytics.js'); | ||
const xhr = new XMLHttpRequest(); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)(()=>{ | ||
xhr.open('GET', 'https://www.google-analytics.com/analytics.js'); | ||
}).not.toThrow(); | ||
}); | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.test)('handles multiple concurrent requests correctly', async ()=>{ | ||
(0, __WEBPACK_EXTERNAL_MODULE__tracking_blocker_js_d038b07a__.createTrackingBlocker)({}, BLOCKED_CONSENT); | ||
const requests = Promise.all([ | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)(fetch('https://www.google-analytics.com/analytics.js')).rejects.toThrow(), | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)(fetch('https://www.google-analytics.com/collect')).rejects.toThrow(), | ||
fetch('https://api.example.com/data') | ||
]); | ||
await requests; | ||
(0, __WEBPACK_EXTERNAL_MODULE_vitest__.expect)(document.dispatchEvent).toHaveBeenCalledTimes(6); | ||
}); | ||
}); |
@@ -9,6 +9,3 @@ import type { AllConsentNames, ConsentState } from '../types'; | ||
*/ | ||
export declare function getEffectiveConsents( | ||
consents: ConsentState, | ||
honorDoNotTrack: boolean | ||
): ConsentState; | ||
export declare function getEffectiveConsents(consents: ConsentState, honorDoNotTrack: boolean): ConsentState; | ||
/** | ||
@@ -22,7 +19,3 @@ * Checks if the user has given consent for a specific type. | ||
*/ | ||
export declare function hasConsentFor( | ||
consentType: AllConsentNames, | ||
consents: ConsentState, | ||
honorDoNotTrack: boolean | ||
): boolean; | ||
export declare function hasConsentFor(consentType: AllConsentNames, consents: ConsentState, honorDoNotTrack: boolean): boolean; | ||
/** | ||
@@ -34,8 +27,6 @@ * Determines if the user has consented based on consent information. | ||
*/ | ||
export declare function hasConsented( | ||
consentInfo: { | ||
time: number; | ||
type: 'all' | 'custom' | 'necessary'; | ||
} | null | ||
): boolean; | ||
export declare function hasConsented(consentInfo: { | ||
time: number; | ||
type: 'all' | 'custom' | 'necessary'; | ||
} | null): boolean; | ||
/** | ||
@@ -48,6 +39,3 @@ * Checks if a specific consent type is enabled. | ||
*/ | ||
export declare function isConsentEnabled( | ||
consentType: AllConsentNames, | ||
consents: ConsentState | ||
): boolean; | ||
//# sourceMappingURL=consent-utils.d.ts.map | ||
export declare function isConsentEnabled(consentType: AllConsentNames, consents: ConsentState): boolean; | ||
//# sourceMappingURL=consent-utils.d.ts.map |
function getEffectiveConsents(consents, honorDoNotTrack) { | ||
if ( | ||
honorDoNotTrack && | ||
'undefined' != typeof window && | ||
'1' === window.navigator.doNotTrack | ||
) | ||
return Object.keys(consents).reduce((acc, key) => { | ||
if (key in consents) acc[key] = 'necessary' === key; | ||
return acc; | ||
}, {}); | ||
return consents; | ||
if (honorDoNotTrack && 'undefined' != typeof window && '1' === window.navigator.doNotTrack) return Object.keys(consents).reduce((acc, key)=>{ | ||
if (key in consents) acc[key] = 'necessary' === key; | ||
return acc; | ||
}, {}); | ||
return consents; | ||
} | ||
function hasConsentFor(consentType, consents, honorDoNotTrack) { | ||
const effectiveConsents = getEffectiveConsents(consents, honorDoNotTrack); | ||
return effectiveConsents[consentType] || false; | ||
const effectiveConsents = getEffectiveConsents(consents, honorDoNotTrack); | ||
return effectiveConsents[consentType] || false; | ||
} | ||
function hasConsented(consentInfo) { | ||
return null !== consentInfo; | ||
return null !== consentInfo; | ||
} | ||
function isConsentEnabled(consentType, consents) { | ||
return consents[consentType] || false; | ||
return consents[consentType] || false; | ||
} | ||
export { getEffectiveConsents, hasConsentFor, hasConsented, isConsentEnabled }; |
@@ -14,12 +14,12 @@ /** | ||
export interface TrackingBlockerConfig { | ||
/** Whether to disable automatic blocking (defaults to false) */ | ||
disableAutomaticBlocking?: boolean; | ||
/** Override the default domain consent map */ | ||
overrideDomainConsentMap?: boolean; | ||
/** Map of domains to their required consent types */ | ||
domainConsentMap?: Record<string, AllConsentNames>; | ||
/** Whether to disable automatic blocking (defaults to false) */ | ||
disableAutomaticBlocking?: boolean; | ||
/** Override the default domain consent map */ | ||
overrideDomainConsentMap?: boolean; | ||
/** Map of domains to their required consent types */ | ||
domainConsentMap?: Record<string, AllConsentNames>; | ||
} | ||
interface TrackingBlocker { | ||
updateConsents: (newConsents: ConsentState) => void; | ||
destroy: () => void; | ||
updateConsents: (newConsents: ConsentState) => void; | ||
destroy: () => void; | ||
} | ||
@@ -29,7 +29,4 @@ /** | ||
*/ | ||
export declare function createTrackingBlocker( | ||
config?: TrackingBlockerConfig, | ||
initialConsents?: ConsentState | ||
): TrackingBlocker; | ||
export declare function createTrackingBlocker(config?: TrackingBlockerConfig, initialConsents?: ConsentState): TrackingBlocker; | ||
export {}; | ||
//# sourceMappingURL=tracking-blocker.d.ts.map | ||
//# sourceMappingURL=tracking-blocker.d.ts.map |
@@ -1,108 +0,86 @@ | ||
import * as __WEBPACK_EXTERNAL_MODULE__tracking_domains_js_60d1a6dc__ from './tracking-domains.js'; | ||
import * as __WEBPACK_EXTERNAL_MODULE__tracking_domains_js_60d1a6dc__ from "./tracking-domains.js"; | ||
function createDefaultConsentState() { | ||
return { | ||
experience: false, | ||
functionality: false, | ||
marketing: false, | ||
measurement: false, | ||
necessary: true, | ||
}; | ||
return { | ||
experience: false, | ||
functionality: false, | ||
marketing: false, | ||
measurement: false, | ||
necessary: true | ||
}; | ||
} | ||
function createTrackingBlocker(config = {}, initialConsents) { | ||
const blockerConfig = { | ||
disableAutomaticBlocking: false, | ||
...config, | ||
domainConsentMap: config.overrideDomainConsentMap | ||
? config.domainConsentMap | ||
: { | ||
...__WEBPACK_EXTERNAL_MODULE__tracking_domains_js_60d1a6dc__[ | ||
'default' | ||
], | ||
...config.domainConsentMap, | ||
}, | ||
}; | ||
let consents = initialConsents || createDefaultConsentState(); | ||
const originalFetch = window.fetch; | ||
const originalXHR = window.XMLHttpRequest; | ||
function normalizeDomain(domain) { | ||
return domain | ||
.toLowerCase() | ||
.replace(/^www\./, '') | ||
.replace(/:\d+$/, '') | ||
.trim(); | ||
} | ||
function findMatchingDomain(domain, domainMap) { | ||
const normalizedDomain = normalizeDomain(domain); | ||
const directMatch = domainMap[normalizedDomain]; | ||
if (directMatch) return directMatch; | ||
for (const [mapDomain, consent] of Object.entries(domainMap)) { | ||
const normalizedMapDomain = normalizeDomain(mapDomain); | ||
if ( | ||
normalizedDomain.endsWith(`.${normalizedMapDomain}`) || | ||
normalizedDomain === normalizedMapDomain | ||
) | ||
return consent; | ||
} | ||
} | ||
function isRequestAllowed(url) { | ||
try { | ||
const domain = new URL(url).hostname; | ||
const requiredConsent = findMatchingDomain( | ||
domain, | ||
blockerConfig.domainConsentMap || {} | ||
); | ||
if (!requiredConsent) return true; | ||
const isAllowed = true === consents[requiredConsent]; | ||
return isAllowed; | ||
} catch (error) { | ||
return true; | ||
} | ||
} | ||
function dispatchConsentBlockedEvent(url) { | ||
document.dispatchEvent( | ||
new CustomEvent('ConsentBlockedRequest', { | ||
detail: { | ||
url, | ||
}, | ||
}) | ||
); | ||
} | ||
function interceptNetworkRequests() { | ||
if (window.fetch === originalFetch) | ||
window.fetch = async (input, init) => { | ||
const url = input instanceof Request ? input.url : input.toString(); | ||
if (!isRequestAllowed(url)) { | ||
dispatchConsentBlockedEvent(url); | ||
return Promise.reject( | ||
new Error(`Request to ${url} blocked due to missing consent`) | ||
); | ||
} | ||
return await originalFetch.call(window, input, init); | ||
}; | ||
if (window.XMLHttpRequest === originalXHR) | ||
window.XMLHttpRequest = class extends originalXHR { | ||
open(method, url, async = true, username, password) { | ||
if (!isRequestAllowed(url.toString())) { | ||
dispatchConsentBlockedEvent(url.toString()); | ||
throw new Error(`Request to ${url} blocked due to missing consent`); | ||
} | ||
super.open(method, url, async, username, password); | ||
} | ||
}; | ||
} | ||
function restoreOriginalRequests() { | ||
if (window.fetch !== originalFetch) window.fetch = originalFetch; | ||
if (window.XMLHttpRequest !== originalXHR) | ||
window.XMLHttpRequest = originalXHR; | ||
} | ||
if (!blockerConfig.disableAutomaticBlocking) interceptNetworkRequests(); | ||
return { | ||
updateConsents: (newConsents) => { | ||
consents = newConsents; | ||
}, | ||
destroy: () => { | ||
restoreOriginalRequests(); | ||
}, | ||
}; | ||
const blockerConfig = { | ||
disableAutomaticBlocking: false, | ||
...config, | ||
domainConsentMap: config.overrideDomainConsentMap ? config.domainConsentMap : { | ||
...__WEBPACK_EXTERNAL_MODULE__tracking_domains_js_60d1a6dc__["default"], | ||
...config.domainConsentMap | ||
} | ||
}; | ||
let consents = initialConsents || createDefaultConsentState(); | ||
const originalFetch = window.fetch; | ||
const originalXHR = window.XMLHttpRequest; | ||
function normalizeDomain(domain) { | ||
return domain.toLowerCase().replace(/^www\./, '').replace(/:\d+$/, '').trim(); | ||
} | ||
function findMatchingDomain(domain, domainMap) { | ||
const normalizedDomain = normalizeDomain(domain); | ||
const directMatch = domainMap[normalizedDomain]; | ||
if (directMatch) return directMatch; | ||
for (const [mapDomain, consent] of Object.entries(domainMap)){ | ||
const normalizedMapDomain = normalizeDomain(mapDomain); | ||
if (normalizedDomain.endsWith(`.${normalizedMapDomain}`) || normalizedDomain === normalizedMapDomain) return consent; | ||
} | ||
} | ||
function isRequestAllowed(url) { | ||
try { | ||
const domain = new URL(url).hostname; | ||
const requiredConsent = findMatchingDomain(domain, blockerConfig.domainConsentMap || {}); | ||
if (!requiredConsent) return true; | ||
const isAllowed = true === consents[requiredConsent]; | ||
return isAllowed; | ||
} catch (error) { | ||
return true; | ||
} | ||
} | ||
function dispatchConsentBlockedEvent(url) { | ||
document.dispatchEvent(new CustomEvent('ConsentBlockedRequest', { | ||
detail: { | ||
url | ||
} | ||
})); | ||
} | ||
function interceptNetworkRequests() { | ||
if (window.fetch === originalFetch) window.fetch = async (input, init)=>{ | ||
const url = input instanceof Request ? input.url : input.toString(); | ||
if (!isRequestAllowed(url)) { | ||
dispatchConsentBlockedEvent(url); | ||
return Promise.reject(new Error(`Request to ${url} blocked due to missing consent`)); | ||
} | ||
return await originalFetch.call(window, input, init); | ||
}; | ||
if (window.XMLHttpRequest === originalXHR) window.XMLHttpRequest = class extends originalXHR { | ||
open(method, url, async = true, username, password) { | ||
if (!isRequestAllowed(url.toString())) { | ||
dispatchConsentBlockedEvent(url.toString()); | ||
throw new Error(`Request to ${url} blocked due to missing consent`); | ||
} | ||
super.open(method, url, async, username, password); | ||
} | ||
}; | ||
} | ||
function restoreOriginalRequests() { | ||
if (window.fetch !== originalFetch) window.fetch = originalFetch; | ||
if (window.XMLHttpRequest !== originalXHR) window.XMLHttpRequest = originalXHR; | ||
} | ||
if (!blockerConfig.disableAutomaticBlocking) interceptNetworkRequests(); | ||
return { | ||
updateConsents: (newConsents)=>{ | ||
consents = newConsents; | ||
}, | ||
destroy: ()=>{ | ||
restoreOriginalRequests(); | ||
} | ||
}; | ||
} | ||
export { createTrackingBlocker }; |
@@ -7,2 +7,2 @@ import type { AllConsentNames } from '../types'; | ||
export default DEFAULT_DOMAIN_CONSENT_MAP; | ||
//# sourceMappingURL=tracking-domains.d.ts.map | ||
//# sourceMappingURL=tracking-domains.d.ts.map |
const DEFAULT_DOMAIN_CONSENT_MAP = { | ||
'www.google-analytics.com': 'measurement', | ||
'analytics.google.com': 'measurement', | ||
'www.googletagmanager.com': 'measurement', | ||
'stats.g.doubleclick.net': 'measurement', | ||
'ampcid.google.com': 'measurement', | ||
'analytics.twitter.com': 'measurement', | ||
'analytics.pinterest.com': 'measurement', | ||
'dc.services.visualstudio.com': 'measurement', | ||
'www.clarity.ms': 'measurement', | ||
'www.hotjar.com': 'measurement', | ||
'static.hotjar.com': 'measurement', | ||
'script.hotjar.com': 'measurement', | ||
'insights.hotjar.com': 'measurement', | ||
'mouseflow.com': 'measurement', | ||
'api.mouseflow.com': 'measurement', | ||
'tools.mouseflow.com': 'measurement', | ||
'cdn.heapanalytics.com': 'measurement', | ||
'plausible.io': 'measurement', | ||
'matomo.cloud': 'measurement', | ||
'matomo.org': 'measurement', | ||
'mixpanel.com': 'measurement', | ||
'api.mixpanel.com': 'measurement', | ||
'sentry.io': 'measurement', | ||
'browser.sentry-cdn.com': 'measurement', | ||
'js.monitor.azure.com': 'measurement', | ||
'stats.wp.com': 'measurement', | ||
'pixel.wp.com': 'measurement', | ||
'analytics.amplitude.com': 'measurement', | ||
'api2.amplitude.com': 'measurement', | ||
'cdn.amplitude.com': 'measurement', | ||
'api.segment.io': 'measurement', | ||
'cdn.segment.com': 'measurement', | ||
'api.segment.com': 'measurement', | ||
'pendo.io': 'measurement', | ||
'data.pendo.io': 'measurement', | ||
'cdn.pendo.io': 'measurement', | ||
'connect.facebook.net': 'marketing', | ||
'platform.twitter.com': 'marketing', | ||
'platform.linkedin.com': 'marketing', | ||
'www.googleadservices.com': 'marketing', | ||
'doubleclick.net': 'marketing', | ||
'googleads.g.doubleclick.net': 'marketing', | ||
'ad.doubleclick.net': 'marketing', | ||
'www.facebook.com': 'marketing', | ||
'ads.linkedin.com': 'marketing', | ||
'ads-api.tiktok.com': 'marketing', | ||
'analytics.tiktok.com': 'marketing', | ||
'business.tiktok.com': 'marketing', | ||
'ads.pinterest.com': 'marketing', | ||
'log.pinterest.com': 'marketing', | ||
'ads-twitter.com': 'marketing', | ||
'static.ads-twitter.com': 'marketing', | ||
'advertising.twitter.com': 'marketing', | ||
'ads.yahoo.com': 'marketing', | ||
'sp.analytics.yahoo.com': 'marketing', | ||
'gemini.yahoo.com': 'marketing', | ||
'adroll.com': 'marketing', | ||
'a.adroll.com': 'marketing', | ||
'd.adroll.com': 'marketing', | ||
's.adroll.com': 'marketing', | ||
'adform.net': 'marketing', | ||
'track.adform.net': 'marketing', | ||
'dmp.adform.net': 'marketing', | ||
'criteo.com': 'marketing', | ||
'static.criteo.net': 'marketing', | ||
'bidder.criteo.com': 'marketing', | ||
'dynamic.criteo.com': 'marketing', | ||
'gum.criteo.com': 'marketing', | ||
'taboola.com': 'marketing', | ||
'cdn.taboola.com': 'marketing', | ||
'trc.taboola.com': 'marketing', | ||
'outbrain.com': 'marketing', | ||
'widgets.outbrain.com': 'marketing', | ||
'tr.outbrain.com': 'marketing', | ||
'amplify.outbrain.com': 'marketing', | ||
'bing.com': 'marketing', | ||
'bat.bing.com': 'marketing', | ||
'clarity.ms': 'marketing', | ||
'quantserve.com': 'marketing', | ||
'secure.quantserve.com': 'marketing', | ||
'pixel.quantserve.com': 'marketing', | ||
'exelator.com': 'marketing', | ||
'load.exelator.com': 'marketing', | ||
'api.exelator.com': 'marketing', | ||
'ad.360yield.com': 'marketing', | ||
'match.360yield.com': 'marketing', | ||
'ad.turn.com': 'marketing', | ||
'r.turn.com': 'marketing', | ||
'd.turn.com': 'marketing', | ||
'cdn.jsdelivr.net': 'functionality', | ||
'ajax.googleapis.com': 'functionality', | ||
'fonts.googleapis.com': 'functionality', | ||
'maps.googleapis.com': 'functionality', | ||
'www.recaptcha.net': 'functionality', | ||
'recaptcha.net': 'functionality', | ||
'www.gstatic.com': 'functionality', | ||
'fonts.gstatic.com': 'functionality', | ||
'cdnjs.cloudflare.com': 'functionality', | ||
'unpkg.com': 'functionality', | ||
'code.jquery.com': 'functionality', | ||
'maxcdn.bootstrapcdn.com': 'functionality', | ||
'cdn.datatables.net': 'functionality', | ||
'js.stripe.com': 'functionality', | ||
'api.stripe.com': 'functionality', | ||
'checkout.stripe.com': 'functionality', | ||
'js.braintreegateway.com': 'functionality', | ||
'api.braintreegateway.com': 'functionality', | ||
'cdn.shopify.com': 'functionality', | ||
'js.intercomcdn.com': 'functionality', | ||
'widget.intercom.io': 'functionality', | ||
'cdn.auth0.com': 'functionality', | ||
'js.pusher.com': 'functionality', | ||
'sockjs.pusher.com': 'functionality', | ||
'app.optimizely.com': 'experience', | ||
'cdn.optimizely.com': 'experience', | ||
'logx.optimizely.com': 'experience', | ||
'cdn.mouseflow.com': 'experience', | ||
'fullstory.com': 'experience', | ||
'rs.fullstory.com': 'experience', | ||
'edge.fullstory.com': 'experience', | ||
'vwo.com': 'experience', | ||
'dev.visualwebsiteoptimizer.com': 'experience', | ||
'assets.adobedtm.com': 'experience', | ||
'cdn.tt.omtrdc.net': 'experience', | ||
'demdex.net': 'experience', | ||
'sc.omtrdc.net': 'experience', | ||
'crazyegg.com': 'experience', | ||
'script.crazyegg.com': 'experience', | ||
'tracking.crazyegg.com': 'experience', | ||
'luckyorange.com': 'experience', | ||
'cdn.luckyorange.com': 'experience', | ||
'w1.luckyorange.com': 'experience', | ||
'upload.luckyorange.com': 'experience', | ||
'clicktale.net': 'experience', | ||
'cdn.clicktale.net': 'experience', | ||
'conductor.clicktale.net': 'experience', | ||
'userzoom.com': 'experience', | ||
'cdn.userzoom.com': 'experience', | ||
'api.userzoom.com': 'experience', | ||
'contentsquare.net': 'experience', | ||
't.contentsquare.net': 'experience', | ||
'app.contentsquare.com': 'experience', | ||
'www.google-analytics.com': 'measurement', | ||
'analytics.google.com': 'measurement', | ||
'www.googletagmanager.com': 'measurement', | ||
'stats.g.doubleclick.net': 'measurement', | ||
'ampcid.google.com': 'measurement', | ||
'analytics.twitter.com': 'measurement', | ||
'analytics.pinterest.com': 'measurement', | ||
'dc.services.visualstudio.com': 'measurement', | ||
'www.clarity.ms': 'measurement', | ||
'www.hotjar.com': 'measurement', | ||
'static.hotjar.com': 'measurement', | ||
"script.hotjar.com": 'measurement', | ||
'insights.hotjar.com': 'measurement', | ||
'mouseflow.com': 'measurement', | ||
'api.mouseflow.com': 'measurement', | ||
'tools.mouseflow.com': 'measurement', | ||
'cdn.heapanalytics.com': 'measurement', | ||
'plausible.io': 'measurement', | ||
'matomo.cloud': 'measurement', | ||
'matomo.org': 'measurement', | ||
'mixpanel.com': 'measurement', | ||
'api.mixpanel.com': 'measurement', | ||
'sentry.io': 'measurement', | ||
'browser.sentry-cdn.com': 'measurement', | ||
'js.monitor.azure.com': 'measurement', | ||
'stats.wp.com': 'measurement', | ||
'pixel.wp.com': 'measurement', | ||
'analytics.amplitude.com': 'measurement', | ||
'api2.amplitude.com': 'measurement', | ||
'cdn.amplitude.com': 'measurement', | ||
'api.segment.io': 'measurement', | ||
'cdn.segment.com': 'measurement', | ||
'api.segment.com': 'measurement', | ||
'pendo.io': 'measurement', | ||
'data.pendo.io': 'measurement', | ||
'cdn.pendo.io': 'measurement', | ||
'connect.facebook.net': 'marketing', | ||
'platform.twitter.com': 'marketing', | ||
'platform.linkedin.com': 'marketing', | ||
'www.googleadservices.com': 'marketing', | ||
'doubleclick.net': 'marketing', | ||
'googleads.g.doubleclick.net': 'marketing', | ||
'ad.doubleclick.net': 'marketing', | ||
'www.facebook.com': 'marketing', | ||
'ads.linkedin.com': 'marketing', | ||
'ads-api.tiktok.com': 'marketing', | ||
'analytics.tiktok.com': 'marketing', | ||
'business.tiktok.com': 'marketing', | ||
'ads.pinterest.com': 'marketing', | ||
'log.pinterest.com': 'marketing', | ||
'ads-twitter.com': 'marketing', | ||
'static.ads-twitter.com': 'marketing', | ||
'advertising.twitter.com': 'marketing', | ||
'ads.yahoo.com': 'marketing', | ||
'sp.analytics.yahoo.com': 'marketing', | ||
'gemini.yahoo.com': 'marketing', | ||
'adroll.com': 'marketing', | ||
'a.adroll.com': 'marketing', | ||
'd.adroll.com': 'marketing', | ||
's.adroll.com': 'marketing', | ||
'adform.net': 'marketing', | ||
'track.adform.net': 'marketing', | ||
'dmp.adform.net': 'marketing', | ||
'criteo.com': 'marketing', | ||
'static.criteo.net': 'marketing', | ||
'bidder.criteo.com': 'marketing', | ||
'dynamic.criteo.com': 'marketing', | ||
'gum.criteo.com': 'marketing', | ||
'taboola.com': 'marketing', | ||
'cdn.taboola.com': 'marketing', | ||
'trc.taboola.com': 'marketing', | ||
'outbrain.com': 'marketing', | ||
'widgets.outbrain.com': 'marketing', | ||
'tr.outbrain.com': 'marketing', | ||
'amplify.outbrain.com': 'marketing', | ||
'bing.com': 'marketing', | ||
'bat.bing.com': 'marketing', | ||
'clarity.ms': 'marketing', | ||
'quantserve.com': 'marketing', | ||
'secure.quantserve.com': 'marketing', | ||
'pixel.quantserve.com': 'marketing', | ||
'exelator.com': 'marketing', | ||
'load.exelator.com': 'marketing', | ||
'api.exelator.com': 'marketing', | ||
'ad.360yield.com': 'marketing', | ||
'match.360yield.com': 'marketing', | ||
'ad.turn.com': 'marketing', | ||
'r.turn.com': 'marketing', | ||
'd.turn.com': 'marketing', | ||
'cdn.jsdelivr.net': 'functionality', | ||
'ajax.googleapis.com': 'functionality', | ||
'fonts.googleapis.com': 'functionality', | ||
'maps.googleapis.com': 'functionality', | ||
'www.recaptcha.net': 'functionality', | ||
'recaptcha.net': 'functionality', | ||
'www.gstatic.com': 'functionality', | ||
'fonts.gstatic.com': 'functionality', | ||
'cdnjs.cloudflare.com': 'functionality', | ||
'unpkg.com': 'functionality', | ||
'code.jquery.com': 'functionality', | ||
'maxcdn.bootstrapcdn.com': 'functionality', | ||
'cdn.datatables.net': 'functionality', | ||
'js.stripe.com': 'functionality', | ||
'api.stripe.com': 'functionality', | ||
'checkout.stripe.com': 'functionality', | ||
'js.braintreegateway.com': 'functionality', | ||
'api.braintreegateway.com': 'functionality', | ||
'cdn.shopify.com': 'functionality', | ||
'js.intercomcdn.com': 'functionality', | ||
'widget.intercom.io': 'functionality', | ||
'cdn.auth0.com': 'functionality', | ||
'js.pusher.com': 'functionality', | ||
'sockjs.pusher.com': 'functionality', | ||
'app.optimizely.com': 'experience', | ||
'cdn.optimizely.com': 'experience', | ||
'logx.optimizely.com': 'experience', | ||
'cdn.mouseflow.com': 'experience', | ||
'fullstory.com': 'experience', | ||
'rs.fullstory.com': 'experience', | ||
'edge.fullstory.com': 'experience', | ||
'vwo.com': 'experience', | ||
'dev.visualwebsiteoptimizer.com': 'experience', | ||
'assets.adobedtm.com': 'experience', | ||
'cdn.tt.omtrdc.net': 'experience', | ||
'demdex.net': 'experience', | ||
'sc.omtrdc.net': 'experience', | ||
'crazyegg.com': 'experience', | ||
"script.crazyegg.com": 'experience', | ||
'tracking.crazyegg.com': 'experience', | ||
'luckyorange.com': 'experience', | ||
'cdn.luckyorange.com': 'experience', | ||
'w1.luckyorange.com': 'experience', | ||
'upload.luckyorange.com': 'experience', | ||
'clicktale.net': 'experience', | ||
'cdn.clicktale.net': 'experience', | ||
'conductor.clicktale.net': 'experience', | ||
'userzoom.com': 'experience', | ||
'cdn.userzoom.com': 'experience', | ||
'api.userzoom.com': 'experience', | ||
'contentsquare.net': 'experience', | ||
't.contentsquare.net': 'experience', | ||
'app.contentsquare.com': 'experience' | ||
}; | ||
const tracking_domains_rslib_entry_ = DEFAULT_DOMAIN_CONSENT_MAP; | ||
export { tracking_domains_rslib_entry_ as default }; |
@@ -9,3 +9,5 @@ /** | ||
interface StoreConfig { | ||
trackingBlockerConfig?: TrackingBlockerConfig; | ||
trackingBlockerConfig?: TrackingBlockerConfig; | ||
/** URL to fetch consent banner information from */ | ||
consentBannerApiUrl?: string; | ||
} | ||
@@ -54,7 +56,4 @@ /** | ||
*/ | ||
export declare const createConsentManagerStore: ( | ||
namespace?: string | undefined, | ||
config?: StoreConfig | ||
) => import('zustand/vanilla').StoreApi<PrivacyConsentState>; | ||
export declare const createConsentManagerStore: (namespace?: string | undefined, config?: StoreConfig) => import("zustand/vanilla").StoreApi<PrivacyConsentState>; | ||
export default createConsentManagerStore; | ||
//# sourceMappingURL=store.d.ts.map | ||
//# sourceMappingURL=store.d.ts.map |
@@ -39,6 +39,3 @@ /** | ||
*/ | ||
export declare const initialState: Omit< | ||
PrivacyConsentState, | ||
'getEffectiveConsents' | 'hasConsentFor' | ||
>; | ||
//# sourceMappingURL=store.initial-state.d.ts.map | ||
export declare const initialState: Omit<PrivacyConsentState, 'getEffectiveConsents' | 'hasConsentFor' | 'fetchConsentBannerInfo'>; | ||
//# sourceMappingURL=store.initial-state.d.ts.map |
@@ -1,66 +0,68 @@ | ||
import * as __WEBPACK_EXTERNAL_MODULE__translations_index_js_8dbce45e__ from './translations/index.js'; | ||
import * as __WEBPACK_EXTERNAL_MODULE__types_index_js_63ede62f__ from './types/index.js'; | ||
import * as __WEBPACK_EXTERNAL_MODULE__translations_index_js_8dbce45e__ from "./translations/index.js"; | ||
import * as __WEBPACK_EXTERNAL_MODULE__types_index_js_63ede62f__ from "./types/index.js"; | ||
const initialState = { | ||
consents: | ||
__WEBPACK_EXTERNAL_MODULE__types_index_js_63ede62f__.consentTypes.reduce( | ||
(acc, consent) => { | ||
acc[consent.name] = consent.defaultValue; | ||
return acc; | ||
}, | ||
{} | ||
), | ||
consentInfo: null, | ||
showPopup: true, | ||
gdprTypes: ['necessary', 'marketing'], | ||
isPrivacyDialogOpen: false, | ||
complianceSettings: { | ||
gdpr: { | ||
enabled: true, | ||
appliesGlobally: true, | ||
applies: true, | ||
}, | ||
ccpa: { | ||
enabled: true, | ||
appliesGlobally: false, | ||
applies: void 0, | ||
}, | ||
lgpd: { | ||
enabled: false, | ||
appliesGlobally: false, | ||
applies: void 0, | ||
}, | ||
usStatePrivacy: { | ||
enabled: true, | ||
appliesGlobally: false, | ||
applies: void 0, | ||
}, | ||
}, | ||
callbacks: {}, | ||
detectedCountry: 'US', | ||
privacySettings: { | ||
honorDoNotTrack: true, | ||
}, | ||
translationConfig: | ||
__WEBPACK_EXTERNAL_MODULE__translations_index_js_8dbce45e__.defaultTranslationConfig, | ||
includeNonDisplayedConsents: false, | ||
consentTypes: | ||
__WEBPACK_EXTERNAL_MODULE__types_index_js_63ede62f__.consentTypes, | ||
setConsent: () => {}, | ||
setShowPopup: () => {}, | ||
setIsPrivacyDialogOpen: () => {}, | ||
saveConsents: () => {}, | ||
resetConsents: () => {}, | ||
setGdprTypes: () => {}, | ||
setComplianceSetting: () => {}, | ||
resetComplianceSettings: () => {}, | ||
setCallback: () => {}, | ||
setDetectedCountry: () => {}, | ||
getDisplayedConsents: () => [], | ||
hasConsented: () => false, | ||
setTranslationConfig: () => {}, | ||
clearAllData: () => {}, | ||
updateConsentMode: () => {}, | ||
setPrivacySettings: () => {}, | ||
setIncludeNonDisplayedConsents: () => {}, | ||
consents: __WEBPACK_EXTERNAL_MODULE__types_index_js_63ede62f__.consentTypes.reduce((acc, consent)=>{ | ||
acc[consent.name] = consent.defaultValue; | ||
return acc; | ||
}, {}), | ||
consentInfo: null, | ||
showPopup: true, | ||
isLoadingConsentInfo: false, | ||
gdprTypes: [ | ||
'necessary', | ||
'marketing' | ||
], | ||
isPrivacyDialogOpen: false, | ||
complianceSettings: { | ||
gdpr: { | ||
enabled: true, | ||
appliesGlobally: true, | ||
applies: true | ||
}, | ||
ccpa: { | ||
enabled: true, | ||
appliesGlobally: false, | ||
applies: void 0 | ||
}, | ||
lgpd: { | ||
enabled: false, | ||
appliesGlobally: false, | ||
applies: void 0 | ||
}, | ||
usStatePrivacy: { | ||
enabled: true, | ||
appliesGlobally: false, | ||
applies: void 0 | ||
} | ||
}, | ||
callbacks: {}, | ||
detectedCountry: null, | ||
locationInfo: null, | ||
jurisdictionInfo: null, | ||
privacySettings: { | ||
honorDoNotTrack: true | ||
}, | ||
translationConfig: __WEBPACK_EXTERNAL_MODULE__translations_index_js_8dbce45e__.defaultTranslationConfig, | ||
includeNonDisplayedConsents: false, | ||
consentTypes: __WEBPACK_EXTERNAL_MODULE__types_index_js_63ede62f__.consentTypes, | ||
setConsent: ()=>{}, | ||
setShowPopup: ()=>{}, | ||
setIsPrivacyDialogOpen: ()=>{}, | ||
saveConsents: ()=>{}, | ||
resetConsents: ()=>{}, | ||
setGdprTypes: ()=>{}, | ||
setComplianceSetting: ()=>{}, | ||
resetComplianceSettings: ()=>{}, | ||
setCallback: ()=>{}, | ||
setDetectedCountry: ()=>{}, | ||
setLocationInfo: ()=>{}, | ||
setJurisdictionInfo: ()=>{}, | ||
getDisplayedConsents: ()=>[], | ||
hasConsented: ()=>false, | ||
setTranslationConfig: ()=>{}, | ||
clearAllData: ()=>{}, | ||
updateConsentMode: ()=>{}, | ||
setPrivacySettings: ()=>{}, | ||
setIncludeNonDisplayedConsents: ()=>{} | ||
}; | ||
export { initialState }; |
@@ -1,219 +0,216 @@ | ||
import * as __WEBPACK_EXTERNAL_MODULE_zustand_vanilla_8a8e4ffb__ from 'zustand/vanilla'; | ||
import * as __WEBPACK_EXTERNAL_MODULE__libs_consent_utils_js_653d35fa__ from './libs/consent-utils.js'; | ||
import * as __WEBPACK_EXTERNAL_MODULE__libs_tracking_blocker_js_b46fe1fa__ from './libs/tracking-blocker.js'; | ||
import * as __WEBPACK_EXTERNAL_MODULE__store_initial_state_js_e62f207b__ from './store.initial-state.js'; | ||
import * as __WEBPACK_EXTERNAL_MODULE__types_index_js_63ede62f__ from './types/index.js'; | ||
import * as __WEBPACK_EXTERNAL_MODULE_zustand_vanilla_8a8e4ffb__ from "zustand/vanilla"; | ||
import * as __WEBPACK_EXTERNAL_MODULE__libs_consent_utils_js_653d35fa__ from "./libs/consent-utils.js"; | ||
import * as __WEBPACK_EXTERNAL_MODULE__libs_fetch_consent_banner_js_d1f1cc72__ from "./libs/fetch-consent-banner.js"; | ||
import * as __WEBPACK_EXTERNAL_MODULE__libs_tracking_blocker_js_b46fe1fa__ from "./libs/tracking-blocker.js"; | ||
import * as __WEBPACK_EXTERNAL_MODULE__store_initial_state_js_e62f207b__ from "./store.initial-state.js"; | ||
import * as __WEBPACK_EXTERNAL_MODULE__types_index_js_63ede62f__ from "./types/index.js"; | ||
const STORAGE_KEY = 'privacy-consent-storage'; | ||
const getStoredConsent = () => { | ||
if ('undefined' == typeof window) return null; | ||
const stored = localStorage.getItem(STORAGE_KEY); | ||
if (!stored) return null; | ||
try { | ||
return JSON.parse(stored); | ||
} catch (e) { | ||
console.error('Failed to parse stored consent:', e); | ||
return null; | ||
} | ||
const getStoredConsent = ()=>{ | ||
if ('undefined' == typeof window) return null; | ||
const stored = localStorage.getItem(STORAGE_KEY); | ||
if (!stored) return null; | ||
try { | ||
return JSON.parse(stored); | ||
} catch (e) { | ||
console.error('Failed to parse stored consent:', e); | ||
return null; | ||
} | ||
}; | ||
const createConsentManagerStore = (namespace = 'c15tStore', config) => { | ||
const storedConsent = getStoredConsent(); | ||
const trackingBlocker = | ||
'undefined' != typeof window | ||
? (0, | ||
__WEBPACK_EXTERNAL_MODULE__libs_tracking_blocker_js_b46fe1fa__.createTrackingBlocker)( | ||
config?.trackingBlockerConfig || {}, | ||
storedConsent?.consents || | ||
__WEBPACK_EXTERNAL_MODULE__store_initial_state_js_e62f207b__ | ||
.initialState.consents | ||
) | ||
: null; | ||
const store = (0, | ||
__WEBPACK_EXTERNAL_MODULE_zustand_vanilla_8a8e4ffb__.createStore)( | ||
(set, get) => ({ | ||
...__WEBPACK_EXTERNAL_MODULE__store_initial_state_js_e62f207b__.initialState, | ||
...(storedConsent | ||
? { | ||
consents: storedConsent.consents, | ||
consentInfo: storedConsent.consentInfo, | ||
showPopup: false, | ||
} | ||
: { | ||
showPopup: true, | ||
}), | ||
setConsent: (name, value) => { | ||
set((state) => { | ||
const consentType = state.consentTypes.find( | ||
(type) => type.name === name | ||
); | ||
if (consentType?.disabled) return state; | ||
const newConsents = { | ||
...state.consents, | ||
[name]: value, | ||
}; | ||
trackingBlocker?.updateConsents(newConsents); | ||
return { | ||
consents: newConsents, | ||
}; | ||
}); | ||
get().updateConsentMode(); | ||
}, | ||
setShowPopup: (show, force = false) => { | ||
const state = get(); | ||
const storedConsent = getStoredConsent(); | ||
if (force || (!storedConsent && !state.consentInfo && show)) | ||
set({ | ||
showPopup: show, | ||
}); | ||
}, | ||
setIsPrivacyDialogOpen: (isOpen) => { | ||
set({ | ||
isPrivacyDialogOpen: isOpen, | ||
}); | ||
}, | ||
saveConsents: (type) => { | ||
const { | ||
callbacks, | ||
updateConsentMode, | ||
consents, | ||
consentTypes, | ||
includeNonDisplayedConsents, | ||
} = get(); | ||
const newConsents = { | ||
...consents, | ||
}; | ||
if ('all' === type) | ||
for (const consent of consentTypes) newConsents[consent.name] = true; | ||
else if ('necessary' === type) | ||
for (const consent of consentTypes) | ||
newConsents[consent.name] = 'necessary' === consent.name; | ||
const consentInfo = { | ||
time: Date.now(), | ||
type: type, | ||
}; | ||
localStorage.setItem( | ||
STORAGE_KEY, | ||
JSON.stringify({ | ||
consents: newConsents, | ||
consentInfo, | ||
}) | ||
); | ||
trackingBlocker?.updateConsents(newConsents); | ||
set({ | ||
consents: newConsents, | ||
showPopup: false, | ||
consentInfo, | ||
}); | ||
updateConsentMode(); | ||
callbacks.onConsentGiven?.(); | ||
callbacks.onPreferenceExpressed?.(); | ||
}, | ||
resetConsents: () => { | ||
set((state) => { | ||
const resetState = { | ||
consents: | ||
__WEBPACK_EXTERNAL_MODULE__types_index_js_63ede62f__.consentTypes.reduce( | ||
(acc, consent) => { | ||
acc[consent.name] = consent.defaultValue; | ||
return acc; | ||
}, | ||
{} | ||
), | ||
consentInfo: null, | ||
}; | ||
localStorage.removeItem(STORAGE_KEY); | ||
return resetState; | ||
}); | ||
}, | ||
setGdprTypes: (types) => | ||
set({ | ||
gdprTypes: types, | ||
}), | ||
setComplianceSetting: (region, settings) => | ||
set((state) => ({ | ||
complianceSettings: { | ||
...state.complianceSettings, | ||
[region]: { | ||
...state.complianceSettings[region], | ||
...settings, | ||
}, | ||
}, | ||
})), | ||
resetComplianceSettings: () => | ||
set({ | ||
complianceSettings: | ||
__WEBPACK_EXTERNAL_MODULE__store_initial_state_js_e62f207b__ | ||
.initialState.complianceSettings, | ||
}), | ||
setCallback: (name, callback) => | ||
set((state) => ({ | ||
callbacks: { | ||
...state.callbacks, | ||
[name]: callback, | ||
}, | ||
})), | ||
setDetectedCountry: (country) => | ||
set({ | ||
detectedCountry: country, | ||
}), | ||
getDisplayedConsents: () => { | ||
const { gdprTypes, consentTypes } = get(); | ||
return consentTypes.filter((consent) => | ||
gdprTypes.includes(consent.name) | ||
); | ||
}, | ||
hasConsented: () => { | ||
const { consentInfo } = get(); | ||
return (0, | ||
__WEBPACK_EXTERNAL_MODULE__libs_consent_utils_js_653d35fa__.hasConsented)( | ||
consentInfo | ||
); | ||
}, | ||
clearAllData: () => { | ||
set( | ||
__WEBPACK_EXTERNAL_MODULE__store_initial_state_js_e62f207b__.initialState | ||
); | ||
localStorage.removeItem(STORAGE_KEY); | ||
}, | ||
updateConsentMode: () => { | ||
get().getEffectiveConsents(); | ||
}, | ||
setPrivacySettings: (settings) => | ||
set((state) => ({ | ||
privacySettings: { | ||
...state.privacySettings, | ||
...settings, | ||
}, | ||
})), | ||
getEffectiveConsents: () => { | ||
const { consents, privacySettings } = get(); | ||
return (0, | ||
__WEBPACK_EXTERNAL_MODULE__libs_consent_utils_js_653d35fa__.getEffectiveConsents)( | ||
consents, | ||
privacySettings.honorDoNotTrack | ||
); | ||
}, | ||
hasConsentFor: (consentType) => { | ||
const { consents, privacySettings } = get(); | ||
return (0, | ||
__WEBPACK_EXTERNAL_MODULE__libs_consent_utils_js_653d35fa__.hasConsentFor)( | ||
consentType, | ||
consents, | ||
privacySettings.honorDoNotTrack | ||
); | ||
}, | ||
setIncludeNonDisplayedConsents: (include) => | ||
set({ | ||
includeNonDisplayedConsents: include, | ||
}), | ||
setTranslationConfig: (config) => { | ||
set({ | ||
translationConfig: config, | ||
}); | ||
}, | ||
}) | ||
); | ||
if ('undefined' != typeof window) window[namespace] = store; | ||
return store; | ||
const createConsentManagerStore = (namespace = 'c15tStore', config)=>{ | ||
const storedConsent = getStoredConsent(); | ||
const trackingBlocker = 'undefined' != typeof window ? (0, __WEBPACK_EXTERNAL_MODULE__libs_tracking_blocker_js_b46fe1fa__.createTrackingBlocker)(config?.trackingBlockerConfig || {}, storedConsent?.consents || __WEBPACK_EXTERNAL_MODULE__store_initial_state_js_e62f207b__.initialState.consents) : null; | ||
const store = (0, __WEBPACK_EXTERNAL_MODULE_zustand_vanilla_8a8e4ffb__.createStore)((set, get)=>({ | ||
...__WEBPACK_EXTERNAL_MODULE__store_initial_state_js_e62f207b__.initialState, | ||
...storedConsent ? { | ||
consents: storedConsent.consents, | ||
consentInfo: storedConsent.consentInfo, | ||
showPopup: false, | ||
isLoadingConsentInfo: false | ||
} : { | ||
showPopup: false, | ||
isLoadingConsentInfo: true | ||
}, | ||
setConsent: (name, value)=>{ | ||
set((state)=>{ | ||
const consentType = state.consentTypes.find((type)=>type.name === name); | ||
if (consentType?.disabled) return state; | ||
const newConsents = { | ||
...state.consents, | ||
[name]: value | ||
}; | ||
trackingBlocker?.updateConsents(newConsents); | ||
return { | ||
consents: newConsents | ||
}; | ||
}); | ||
get().updateConsentMode(); | ||
}, | ||
setShowPopup: (show, force = false)=>{ | ||
const state = get(); | ||
const storedConsent = getStoredConsent(); | ||
if (force || !storedConsent && !state.consentInfo && !state.isLoadingConsentInfo && show) set({ | ||
showPopup: show | ||
}); | ||
}, | ||
setIsPrivacyDialogOpen: (isOpen)=>{ | ||
set({ | ||
isPrivacyDialogOpen: isOpen | ||
}); | ||
}, | ||
saveConsents: (type)=>{ | ||
const { callbacks, updateConsentMode, consents, consentTypes, includeNonDisplayedConsents } = get(); | ||
const newConsents = { | ||
...consents | ||
}; | ||
if ('all' === type) for (const consent of consentTypes)newConsents[consent.name] = true; | ||
else if ('necessary' === type) for (const consent of consentTypes)newConsents[consent.name] = 'necessary' === consent.name; | ||
const consentInfo = { | ||
time: Date.now(), | ||
type: type | ||
}; | ||
localStorage.setItem(STORAGE_KEY, JSON.stringify({ | ||
consents: newConsents, | ||
consentInfo | ||
})); | ||
trackingBlocker?.updateConsents(newConsents); | ||
set({ | ||
consents: newConsents, | ||
showPopup: false, | ||
consentInfo | ||
}); | ||
updateConsentMode(); | ||
callbacks.onConsentGiven?.(); | ||
callbacks.onPreferenceExpressed?.(); | ||
}, | ||
resetConsents: ()=>{ | ||
set((state)=>{ | ||
const resetState = { | ||
consents: __WEBPACK_EXTERNAL_MODULE__types_index_js_63ede62f__.consentTypes.reduce((acc, consent)=>{ | ||
acc[consent.name] = consent.defaultValue; | ||
return acc; | ||
}, {}), | ||
consentInfo: null | ||
}; | ||
localStorage.removeItem(STORAGE_KEY); | ||
return resetState; | ||
}); | ||
}, | ||
setGdprTypes: (types)=>set({ | ||
gdprTypes: types | ||
}), | ||
setComplianceSetting: (region, settings)=>set((state)=>({ | ||
complianceSettings: { | ||
...state.complianceSettings, | ||
[region]: { | ||
...state.complianceSettings[region], | ||
...settings | ||
} | ||
} | ||
})), | ||
resetComplianceSettings: ()=>set({ | ||
complianceSettings: __WEBPACK_EXTERNAL_MODULE__store_initial_state_js_e62f207b__.initialState.complianceSettings | ||
}), | ||
setCallback: (name, callback)=>set((state)=>({ | ||
callbacks: { | ||
...state.callbacks, | ||
[name]: callback | ||
} | ||
})), | ||
setDetectedCountry: (country)=>set({ | ||
detectedCountry: country | ||
}), | ||
setLocationInfo: (location)=>set({ | ||
locationInfo: location | ||
}), | ||
setJurisdictionInfo: (jurisdiction)=>set({ | ||
jurisdictionInfo: jurisdiction | ||
}), | ||
fetchConsentBannerInfo: async (url)=>{ | ||
if ('undefined' == typeof window) return; | ||
if (get().hasConsented()) { | ||
set({ | ||
isLoadingConsentInfo: false | ||
}); | ||
return; | ||
} | ||
set({ | ||
isLoadingConsentInfo: true | ||
}); | ||
try { | ||
const apiUrl = url || config?.consentBannerApiUrl || __WEBPACK_EXTERNAL_MODULE__libs_fetch_consent_banner_js_d1f1cc72__.DEFAULT_CONSENT_BANNER_API_URL; | ||
return await (0, __WEBPACK_EXTERNAL_MODULE__libs_fetch_consent_banner_js_d1f1cc72__.fetchConsentBannerInfo)(get().hasConsented, (data)=>{ | ||
set({ | ||
locationInfo: data.location, | ||
jurisdictionInfo: data.jurisdiction, | ||
isLoadingConsentInfo: false, | ||
...null === get().consentInfo ? { | ||
showPopup: data.showConsentBanner | ||
} : {} | ||
}); | ||
if (data.location?.countryCode) get().setDetectedCountry(data.location.countryCode); | ||
get().callbacks.onLocationDetected?.(data.location); | ||
}, (errorMessage)=>{ | ||
set({ | ||
isLoadingConsentInfo: false | ||
}); | ||
get().callbacks.onError?.(errorMessage); | ||
if (null === get().consentInfo) set({ | ||
showPopup: true | ||
}); | ||
}, apiUrl); | ||
} catch (error) { | ||
console.error('Unexpected error in fetchConsentBannerInfo:', error); | ||
set({ | ||
isLoadingConsentInfo: false | ||
}); | ||
return; | ||
} | ||
}, | ||
getDisplayedConsents: ()=>{ | ||
const { gdprTypes, consentTypes } = get(); | ||
return consentTypes.filter((consent)=>gdprTypes.includes(consent.name)); | ||
}, | ||
hasConsented: ()=>{ | ||
const { consentInfo } = get(); | ||
return (0, __WEBPACK_EXTERNAL_MODULE__libs_consent_utils_js_653d35fa__.hasConsented)(consentInfo); | ||
}, | ||
clearAllData: ()=>{ | ||
set(__WEBPACK_EXTERNAL_MODULE__store_initial_state_js_e62f207b__.initialState); | ||
localStorage.removeItem(STORAGE_KEY); | ||
}, | ||
updateConsentMode: ()=>{ | ||
get().getEffectiveConsents(); | ||
}, | ||
setPrivacySettings: (settings)=>set((state)=>({ | ||
privacySettings: { | ||
...state.privacySettings, | ||
...settings | ||
} | ||
})), | ||
getEffectiveConsents: ()=>{ | ||
const { consents, privacySettings } = get(); | ||
return (0, __WEBPACK_EXTERNAL_MODULE__libs_consent_utils_js_653d35fa__.getEffectiveConsents)(consents, privacySettings.honorDoNotTrack); | ||
}, | ||
hasConsentFor: (consentType)=>{ | ||
const { consents, privacySettings } = get(); | ||
return (0, __WEBPACK_EXTERNAL_MODULE__libs_consent_utils_js_653d35fa__.hasConsentFor)(consentType, consents, privacySettings.honorDoNotTrack); | ||
}, | ||
setIncludeNonDisplayedConsents: (include)=>set({ | ||
includeNonDisplayedConsents: include | ||
}), | ||
setTranslationConfig: (config)=>{ | ||
set({ | ||
translationConfig: config | ||
}); | ||
} | ||
})); | ||
if ('undefined' != typeof window) { | ||
window[namespace] = store; | ||
if (!getStoredConsent()) store.getState().fetchConsentBannerInfo().catch(()=>{ | ||
console.log('Failed to fetch consent banner information, defaulting to showing banner'); | ||
}); | ||
} | ||
return store; | ||
}; | ||
const store_rslib_entry_ = createConsentManagerStore; | ||
export { createConsentManagerStore, store_rslib_entry_ as default }; |
@@ -5,14 +5,3 @@ /** | ||
*/ | ||
import type { | ||
AllConsentNames, | ||
CallbackFunction, | ||
Callbacks, | ||
ComplianceRegion, | ||
ComplianceSettings, | ||
ConsentState, | ||
ConsentType, | ||
PrivacySettings, | ||
TranslationConfig, | ||
consentTypes, | ||
} from './types'; | ||
import type { AllConsentNames, CallbackFunction, Callbacks, ComplianceRegion, ComplianceSettings, ConsentBannerResponse, ConsentState, ConsentType, JurisdictionInfo, LocationInfo, PrivacySettings, TranslationConfig, consentTypes } from './types'; | ||
/** | ||
@@ -49,118 +38,134 @@ * Core state and methods interface for the privacy consent management store. | ||
export interface PrivacyConsentState { | ||
/** Current consent states for all consent types */ | ||
consents: ConsentState; | ||
/** Information about when and how consent was given */ | ||
consentInfo: { | ||
time: number; | ||
type: 'all' | 'custom' | 'necessary'; | ||
} | null; | ||
/** Whether to show the consent popup */ | ||
showPopup: boolean; | ||
/** Active GDPR consent types */ | ||
gdprTypes: AllConsentNames[]; | ||
/** Whether the privacy dialog is currently open */ | ||
isPrivacyDialogOpen: boolean; | ||
/** Region-specific compliance settings */ | ||
complianceSettings: Record<ComplianceRegion, ComplianceSettings>; | ||
/** Event callbacks for consent actions */ | ||
callbacks: Callbacks; | ||
/** User's detected country code */ | ||
detectedCountry: string; | ||
/** Privacy-related settings */ | ||
privacySettings: PrivacySettings; | ||
/** Translation configuration */ | ||
translationConfig: TranslationConfig; | ||
/** | ||
* Updates the translation configuration. | ||
* @param config - The new translation configuration | ||
*/ | ||
setTranslationConfig: (config: TranslationConfig) => void; | ||
/** Whether to include non-displayed consents in operations */ | ||
includeNonDisplayedConsents: boolean; | ||
/** Available consent type configurations */ | ||
consentTypes: ConsentType[]; | ||
/** | ||
* Updates the consent state for a specific consent type. | ||
* @param name - The consent type to update | ||
* @param value - The new consent value | ||
*/ | ||
setConsent: (name: AllConsentNames, value: boolean) => void; | ||
/** | ||
* Controls the visibility of the consent popup. | ||
* @param show - Whether to show the popup | ||
*/ | ||
/** | ||
* Controls the visibility of the consent popup. | ||
* @param show - Whether to show the popup | ||
* @param force - When true, forcefully updates the popup state regardless of current consent customization | ||
*/ | ||
setShowPopup: (show: boolean, force?: boolean) => void; | ||
/** | ||
* Controls the visibility of the privacy dialog. | ||
* @param isOpen - Whether the dialog should be open | ||
*/ | ||
setIsPrivacyDialogOpen: (isOpen: boolean) => void; | ||
/** | ||
* Saves the user's consent preferences. | ||
* @param type - The type of consent being saved | ||
*/ | ||
saveConsents: (type: 'all' | 'custom' | 'necessary') => void; | ||
/** Resets all consent preferences to their default values */ | ||
resetConsents: () => void; | ||
/** | ||
* Updates the active GDPR consent types. | ||
* @param types - Array of consent types to activate | ||
*/ | ||
setGdprTypes: (types: AllConsentNames[]) => void; | ||
/** | ||
* Updates compliance settings for a specific region. | ||
* @param region - The region to update | ||
* @param settings - New compliance settings | ||
*/ | ||
setComplianceSetting: ( | ||
region: ComplianceRegion, | ||
settings: Partial<ComplianceSettings> | ||
) => void; | ||
/** Resets compliance settings to their default values */ | ||
resetComplianceSettings: () => void; | ||
/** | ||
* Sets a callback for a specific consent event. | ||
* @param name - The callback event name | ||
* @param callback - The callback function | ||
*/ | ||
setCallback: ( | ||
name: keyof Callbacks, | ||
callback: CallbackFunction | undefined | ||
) => void; | ||
/** | ||
* Updates the user's detected country. | ||
* @param country - The country code | ||
*/ | ||
setDetectedCountry: (country: string) => void; | ||
/** Retrieves the list of consent types that should be displayed */ | ||
getDisplayedConsents: () => typeof consentTypes; | ||
/** Checks if the user has provided any form of consent */ | ||
hasConsented: () => boolean; | ||
/** Clears all consent data and resets to initial state */ | ||
clearAllData: () => void; | ||
/** Updates the consent mode in external systems (e.g., analytics) */ | ||
updateConsentMode: () => void; | ||
/** | ||
* Updates privacy-related settings. | ||
* @param settings - New privacy settings | ||
*/ | ||
setPrivacySettings: (settings: Partial<PrivacySettings>) => void; | ||
/** Gets the effective consent states after applying privacy settings */ | ||
getEffectiveConsents: () => ConsentState; | ||
/** | ||
* Checks if consent has been given for a specific type. | ||
* @param consentType - The consent type to check | ||
*/ | ||
hasConsentFor: (consentType: AllConsentNames) => boolean; | ||
/** | ||
* Controls whether non-displayed consents should be included. | ||
* @param include - Whether to include non-displayed consents | ||
*/ | ||
setIncludeNonDisplayedConsents: (include: boolean) => void; | ||
/** Current consent states for all consent types */ | ||
consents: ConsentState; | ||
/** Information about when and how consent was given */ | ||
consentInfo: { | ||
time: number; | ||
type: 'all' | 'custom' | 'necessary'; | ||
} | null; | ||
/** Whether to show the consent popup */ | ||
showPopup: boolean; | ||
/** Whether consent banner information is currently being loaded */ | ||
isLoadingConsentInfo: boolean; | ||
/** Active GDPR consent types */ | ||
gdprTypes: AllConsentNames[]; | ||
/** Whether the privacy dialog is currently open */ | ||
isPrivacyDialogOpen: boolean; | ||
/** Region-specific compliance settings */ | ||
complianceSettings: Record<ComplianceRegion, ComplianceSettings>; | ||
/** Event callbacks for consent actions */ | ||
callbacks: Callbacks; | ||
/** User's detected country code */ | ||
detectedCountry: string | null; | ||
/** User's location information */ | ||
locationInfo: LocationInfo | null; | ||
/** Applicable jurisdiction information */ | ||
jurisdictionInfo: JurisdictionInfo | null; | ||
/** Privacy-related settings */ | ||
privacySettings: PrivacySettings; | ||
/** Translation configuration */ | ||
translationConfig: TranslationConfig; | ||
/** | ||
* Updates the translation configuration. | ||
* @param config - The new translation configuration | ||
*/ | ||
setTranslationConfig: (config: TranslationConfig) => void; | ||
/** Whether to include non-displayed consents in operations */ | ||
includeNonDisplayedConsents: boolean; | ||
/** Available consent type configurations */ | ||
consentTypes: ConsentType[]; | ||
/** | ||
* Updates the consent state for a specific consent type. | ||
* @param name - The consent type to update | ||
* @param value - The new consent value | ||
*/ | ||
setConsent: (name: AllConsentNames, value: boolean) => void; | ||
/** | ||
* Controls the visibility of the consent popup. | ||
* @param show - Whether to show the popup | ||
*/ | ||
/** | ||
* Controls the visibility of the consent popup. | ||
* @param show - Whether to show the popup | ||
* @param force - When true, forcefully updates the popup state regardless of current consent customization | ||
*/ | ||
setShowPopup: (show: boolean, force?: boolean) => void; | ||
/** | ||
* Controls the visibility of the privacy dialog. | ||
* @param isOpen - Whether the dialog should be open | ||
*/ | ||
setIsPrivacyDialogOpen: (isOpen: boolean) => void; | ||
/** | ||
* Saves the user's consent preferences. | ||
* @param type - The type of consent being saved | ||
*/ | ||
saveConsents: (type: 'all' | 'custom' | 'necessary') => void; | ||
/** Resets all consent preferences to their default values */ | ||
resetConsents: () => void; | ||
/** | ||
* Updates the active GDPR consent types. | ||
* @param types - Array of consent types to activate | ||
*/ | ||
setGdprTypes: (types: AllConsentNames[]) => void; | ||
/** | ||
* Updates compliance settings for a specific region. | ||
* @param region - The region to update | ||
* @param settings - New compliance settings | ||
*/ | ||
setComplianceSetting: (region: ComplianceRegion, settings: Partial<ComplianceSettings>) => void; | ||
/** Resets compliance settings to their default values */ | ||
resetComplianceSettings: () => void; | ||
/** | ||
* Sets a callback for a specific consent event. | ||
* @param name - The callback event name | ||
* @param callback - The callback function | ||
*/ | ||
setCallback: (name: keyof Callbacks, callback: CallbackFunction | undefined) => void; | ||
/** | ||
* Updates the user's detected country. | ||
* @param country - The country code | ||
*/ | ||
setDetectedCountry: (country: string) => void; | ||
/** | ||
* Updates the user's location information. | ||
* @param location - The location information | ||
*/ | ||
setLocationInfo: (location: LocationInfo | null) => void; | ||
/** | ||
* Updates the applicable jurisdiction information. | ||
* @param jurisdiction - The jurisdiction information | ||
*/ | ||
setJurisdictionInfo: (jurisdiction: JurisdictionInfo | null) => void; | ||
/** | ||
* Fetches consent banner information from the API and updates the store. | ||
* @param url - The URL to fetch consent banner information from | ||
* @returns A promise that resolves with the consent banner response when the fetch is complete, or undefined if it fails | ||
*/ | ||
fetchConsentBannerInfo: (url?: string) => Promise<ConsentBannerResponse | undefined>; | ||
/** Retrieves the list of consent types that should be displayed */ | ||
getDisplayedConsents: () => typeof consentTypes; | ||
/** Checks if the user has provided any form of consent */ | ||
hasConsented: () => boolean; | ||
/** Clears all consent data and resets to initial state */ | ||
clearAllData: () => void; | ||
/** Updates the consent mode in external systems (e.g., analytics) */ | ||
updateConsentMode: () => void; | ||
/** | ||
* Updates privacy-related settings. | ||
* @param settings - New privacy settings | ||
*/ | ||
setPrivacySettings: (settings: Partial<PrivacySettings>) => void; | ||
/** Gets the effective consent states after applying privacy settings */ | ||
getEffectiveConsents: () => ConsentState; | ||
/** | ||
* Checks if consent has been given for a specific type. | ||
* @param consentType - The consent type to check | ||
*/ | ||
hasConsentFor: (consentType: AllConsentNames) => boolean; | ||
/** | ||
* Controls whether non-displayed consents should be included. | ||
* @param include - Whether to include non-displayed consents | ||
*/ | ||
setIncludeNonDisplayedConsents: (include: boolean) => void; | ||
} | ||
//# sourceMappingURL=store.type.d.ts.map | ||
//# sourceMappingURL=store.type.d.ts.map |
import type { CompleteTranslations } from '../types/translations'; | ||
export declare const enTranslations: CompleteTranslations; | ||
//# sourceMappingURL=en.d.ts.map | ||
//# sourceMappingURL=en.d.ts.map |
const enTranslations = { | ||
cookieBanner: { | ||
title: 'We value your privacy', | ||
description: | ||
'This site uses cookies to improve your browsing experience, analyze site traffic, and show personalized content.', | ||
acceptAll: 'Accept All', | ||
rejectAll: 'Reject All', | ||
customize: 'Customize', | ||
}, | ||
consentManagerDialog: { | ||
title: 'Privacy Settings', | ||
description: | ||
'Customize your privacy settings here. You can choose which types of cookies and tracking technologies you allow.', | ||
save: 'Save Settings', | ||
acceptAll: 'Accept All', | ||
rejectAll: 'Reject All', | ||
close: 'Close', | ||
}, | ||
consentManagerWidget: { | ||
title: 'Privacy Preferences', | ||
description: 'Manage your privacy settings', | ||
save: 'Save Settings', | ||
acceptAll: 'Accept All', | ||
rejectAll: 'Reject All', | ||
}, | ||
consentTypes: { | ||
necessary: { | ||
title: 'Strictly Necessary', | ||
description: | ||
'These cookies are essential for the website to function properly and cannot be disabled.', | ||
}, | ||
functionality: { | ||
title: 'Functionality', | ||
description: | ||
'These cookies enable enhanced functionality and personalization of the website.', | ||
}, | ||
marketing: { | ||
title: 'Marketing', | ||
description: | ||
'These cookies are used to deliver relevant advertisements and track their effectiveness.', | ||
}, | ||
measurement: { | ||
title: 'Analytics', | ||
description: | ||
'These cookies help us understand how visitors interact with the website and improve its performance.', | ||
}, | ||
experience: { | ||
title: 'Experience', | ||
description: | ||
'These cookies help us provide a better user experience and test new features.', | ||
}, | ||
}, | ||
cookieBanner: { | ||
title: 'We value your privacy', | ||
description: 'This site uses cookies to improve your browsing experience, analyze site traffic, and show personalized content.', | ||
acceptAll: 'Accept All', | ||
rejectAll: 'Reject All', | ||
customize: 'Customize' | ||
}, | ||
consentManagerDialog: { | ||
title: 'Privacy Settings', | ||
description: 'Customize your privacy settings here. You can choose which types of cookies and tracking technologies you allow.', | ||
save: 'Save Settings', | ||
acceptAll: 'Accept All', | ||
rejectAll: 'Reject All', | ||
close: 'Close' | ||
}, | ||
consentManagerWidget: { | ||
title: 'Privacy Preferences', | ||
description: 'Manage your privacy settings', | ||
save: 'Save Settings', | ||
acceptAll: 'Accept All', | ||
rejectAll: 'Reject All' | ||
}, | ||
consentTypes: { | ||
necessary: { | ||
title: 'Strictly Necessary', | ||
description: 'These cookies are essential for the website to function properly and cannot be disabled.' | ||
}, | ||
functionality: { | ||
title: 'Functionality', | ||
description: 'These cookies enable enhanced functionality and personalization of the website.' | ||
}, | ||
marketing: { | ||
title: 'Marketing', | ||
description: 'These cookies are used to deliver relevant advertisements and track their effectiveness.' | ||
}, | ||
measurement: { | ||
title: 'Analytics', | ||
description: 'These cookies help us understand how visitors interact with the website and improve its performance.' | ||
}, | ||
experience: { | ||
title: 'Experience', | ||
description: 'These cookies help us provide a better user experience and test new features.' | ||
} | ||
} | ||
}; | ||
export { enTranslations }; |
import type { TranslationConfig } from '../types/translations'; | ||
export declare const defaultTranslationConfig: TranslationConfig; | ||
//# sourceMappingURL=index.d.ts.map | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,9 +0,9 @@ | ||
import * as __WEBPACK_EXTERNAL_MODULE__en_js_1898771b__ from './en.js'; | ||
import * as __WEBPACK_EXTERNAL_MODULE__en_js_1898771b__ from "./en.js"; | ||
const defaultTranslationConfig = { | ||
translations: { | ||
en: __WEBPACK_EXTERNAL_MODULE__en_js_1898771b__.enTranslations, | ||
}, | ||
defaultLanguage: 'en', | ||
disableAutoLanguageSwitch: false, | ||
translations: { | ||
en: __WEBPACK_EXTERNAL_MODULE__en_js_1898771b__.enTranslations | ||
}, | ||
defaultLanguage: 'en', | ||
disableAutoLanguageSwitch: false | ||
}; | ||
export { defaultTranslationConfig }; |
@@ -26,2 +26,3 @@ /** | ||
export type CallbackFunction<T = void> = (arg: T) => void; | ||
import type { LocationInfo } from './compliance'; | ||
/** | ||
@@ -129,20 +130,25 @@ * Defines the structure for callback functions that respond to consent-related events. | ||
export interface Callbacks { | ||
/** Called when the consent management system is fully initialized and ready */ | ||
onReady?: CallbackFunction; | ||
/** Called when the consent banner becomes visible to the user */ | ||
onBannerShown?: CallbackFunction; | ||
/** Called when the consent banner is dismissed or hidden */ | ||
onBannerClosed?: CallbackFunction; | ||
/** Called when the user grants consent for one or more purposes */ | ||
onConsentGiven?: CallbackFunction; | ||
/** Called when the user denies consent for one or more purposes */ | ||
onConsentRejected?: CallbackFunction; | ||
/** Called when the user makes any change to their consent preferences */ | ||
onPreferenceExpressed?: CallbackFunction; | ||
/** | ||
* Called when an error occurs in the consent management system | ||
* @param errorMessage - A description of the error that occurred | ||
*/ | ||
onError?: CallbackFunction<string>; | ||
/** Called when the consent management system is fully initialized and ready */ | ||
onReady?: CallbackFunction; | ||
/** Called when the consent banner becomes visible to the user */ | ||
onBannerShown?: CallbackFunction; | ||
/** Called when the consent banner is dismissed or hidden */ | ||
onBannerClosed?: CallbackFunction; | ||
/** Called when the user grants consent for one or more purposes */ | ||
onConsentGiven?: CallbackFunction; | ||
/** Called when the user denies consent for one or more purposes */ | ||
onConsentRejected?: CallbackFunction; | ||
/** Called when the user makes any change to their consent preferences */ | ||
onPreferenceExpressed?: CallbackFunction; | ||
/** | ||
* Called when an error occurs in the consent management system | ||
* @param errorMessage - A description of the error that occurred | ||
*/ | ||
onError?: CallbackFunction<string>; | ||
/** | ||
* Called when the user's location is detected | ||
* @param location - The detected location information | ||
*/ | ||
onLocationDetected?: CallbackFunction<LocationInfo>; | ||
} | ||
//# sourceMappingURL=callbacks.d.ts.map | ||
//# sourceMappingURL=callbacks.d.ts.map |
@@ -81,8 +81,8 @@ import type { AllConsentNames } from './gdpr'; | ||
export type ComplianceSettings = { | ||
/** Whether the compliance framework is active */ | ||
enabled: boolean; | ||
/** Whether to apply compliance rules globally */ | ||
appliesGlobally: boolean; | ||
/** Whether the regulation applies in current context */ | ||
applies: boolean | undefined; | ||
/** Whether the compliance framework is active */ | ||
enabled: boolean; | ||
/** Whether to apply compliance rules globally */ | ||
appliesGlobally: boolean; | ||
/** Whether the regulation applies in current context */ | ||
applies: boolean | undefined; | ||
}; | ||
@@ -118,4 +118,4 @@ /** | ||
export type PrivacySettings = { | ||
/** Whether to respect the browser's Do Not Track setting */ | ||
honorDoNotTrack: boolean; | ||
/** Whether to respect the browser's Do Not Track setting */ | ||
honorDoNotTrack: boolean; | ||
}; | ||
@@ -156,6 +156,6 @@ /** | ||
export type HasConsentedProps = { | ||
/** Timestamp when consent was given */ | ||
time: number; | ||
/** Type of consent granted */ | ||
type: 'all' | 'custom' | 'necessary'; | ||
/** Timestamp when consent was given */ | ||
time: number; | ||
/** Type of consent granted */ | ||
type: 'all' | 'custom' | 'necessary'; | ||
} | null; | ||
@@ -192,9 +192,84 @@ /** | ||
export type NamespaceProps = { | ||
/** | ||
* Global namespace for the consent manager store. | ||
* | ||
* @defaultValue "c15tStore" | ||
*/ | ||
namespace?: string; | ||
/** | ||
* Global namespace for the consent manager store. | ||
* | ||
* @defaultValue "c15tStore" | ||
*/ | ||
namespace?: string; | ||
}; | ||
//# sourceMappingURL=compliance.d.ts.map | ||
/** | ||
* Represents location information for the user. | ||
* | ||
* @remarks | ||
* Contains country and region codes to determine applicable privacy regulations. | ||
* | ||
* @example | ||
* ```typescript | ||
* const location: LocationInfo = { | ||
* countryCode: 'GB', | ||
* regionCode: 'ENG' | ||
* }; | ||
* ``` | ||
* | ||
* @public | ||
*/ | ||
export type LocationInfo = { | ||
/** ISO country code (e.g., 'US', 'GB', 'DE') */ | ||
countryCode: string; | ||
/** Region or state code within the country (e.g., 'CA', 'ENG') */ | ||
regionCode?: string; | ||
}; | ||
/** | ||
* Represents jurisdiction information for consent requirements. | ||
* | ||
* @remarks | ||
* Identifies which privacy regulation applies and provides context. | ||
* | ||
* @example | ||
* ```typescript | ||
* const jurisdiction: JurisdictionInfo = { | ||
* code: 'GDPR', | ||
* message: 'GDPR or equivalent regulations require a cookie banner.' | ||
* }; | ||
* ``` | ||
* | ||
* @public | ||
*/ | ||
export type JurisdictionInfo = { | ||
/** Code identifying the applicable regulation (e.g., 'GDPR', 'CCPA') */ | ||
code: string; | ||
/** Human-readable message explaining the regulation requirement */ | ||
message: string; | ||
}; | ||
/** | ||
* Response from the consent banner API. | ||
* | ||
* @remarks | ||
* Contains information about whether to show the consent banner and why. | ||
* | ||
* @example | ||
* ```typescript | ||
* const response: ConsentBannerResponse = { | ||
* showConsentBanner: true, | ||
* jurisdiction: { | ||
* code: 'GDPR', | ||
* message: 'GDPR or equivalent regulations require a cookie banner.' | ||
* }, | ||
* location: { | ||
* countryCode: 'GB', | ||
* regionCode: 'ENG' | ||
* } | ||
* }; | ||
* ``` | ||
* | ||
* @public | ||
*/ | ||
export type ConsentBannerResponse = { | ||
/** Whether to show the consent banner */ | ||
showConsentBanner: boolean; | ||
/** Information about the applicable jurisdiction */ | ||
jurisdiction: JurisdictionInfo; | ||
/** Information about the user's location */ | ||
location: LocationInfo; | ||
}; | ||
//# sourceMappingURL=compliance.d.ts.map |
@@ -38,8 +38,3 @@ /** | ||
*/ | ||
export type AllConsentNames = | ||
| 'experience' | ||
| 'functionality' | ||
| 'marketing' | ||
| 'measurement' | ||
| 'necessary'; | ||
export type AllConsentNames = 'experience' | 'functionality' | 'marketing' | 'measurement' | 'necessary'; | ||
/** | ||
@@ -103,14 +98,14 @@ * Defines the configuration structure for each consent type. | ||
export type ConsentType = { | ||
/** Whether consent is granted by default */ | ||
defaultValue: boolean; | ||
/** User-friendly description of what this consent enables */ | ||
description: string; | ||
/** Whether users can modify this consent setting */ | ||
disabled?: boolean; | ||
/** Whether to show this consent option in the UI */ | ||
display: boolean; | ||
/** GDPR category identifier (1-5) */ | ||
gdprType: number; | ||
/** The consent category name */ | ||
name: AllConsentNames; | ||
/** Whether consent is granted by default */ | ||
defaultValue: boolean; | ||
/** User-friendly description of what this consent enables */ | ||
description: string; | ||
/** Whether users can modify this consent setting */ | ||
disabled?: boolean; | ||
/** Whether to show this consent option in the UI */ | ||
display: boolean; | ||
/** GDPR category identifier (1-5) */ | ||
gdprType: number; | ||
/** The consent category name */ | ||
name: AllConsentNames; | ||
}; | ||
@@ -170,2 +165,2 @@ /** | ||
export declare const consentTypes: ConsentType[]; | ||
//# sourceMappingURL=gdpr.d.ts.map | ||
//# sourceMappingURL=gdpr.d.ts.map |
const consentTypes = [ | ||
{ | ||
defaultValue: true, | ||
description: | ||
'These trackers are used for activities that are strictly necessary to operate or deliver the service you requested from us and, therefore, do not require you to consent.', | ||
disabled: true, | ||
display: true, | ||
gdprType: 1, | ||
name: 'necessary', | ||
}, | ||
{ | ||
defaultValue: false, | ||
description: | ||
'These trackers enable basic interactions and functionalities that allow you to access selected features of our service and facilitate your communication with us.', | ||
display: false, | ||
gdprType: 2, | ||
name: 'functionality', | ||
}, | ||
{ | ||
defaultValue: false, | ||
description: | ||
'These trackers help us to measure traffic and analyze your behavior to improve our service.', | ||
display: false, | ||
gdprType: 4, | ||
name: 'measurement', | ||
}, | ||
{ | ||
defaultValue: false, | ||
description: | ||
'These trackers help us to improve the quality of your user experience and enable interactions with external content, networks, and platforms.', | ||
display: false, | ||
gdprType: 3, | ||
name: 'experience', | ||
}, | ||
{ | ||
defaultValue: false, | ||
description: | ||
'These trackers help us to deliver personalized ads or marketing content to you, and to measure their performance.', | ||
display: false, | ||
gdprType: 5, | ||
name: 'marketing', | ||
}, | ||
{ | ||
defaultValue: true, | ||
description: 'These trackers are used for activities that are strictly necessary to operate or deliver the service you requested from us and, therefore, do not require you to consent.', | ||
disabled: true, | ||
display: true, | ||
gdprType: 1, | ||
name: 'necessary' | ||
}, | ||
{ | ||
defaultValue: false, | ||
description: 'These trackers enable basic interactions and functionalities that allow you to access selected features of our service and facilitate your communication with us.', | ||
display: false, | ||
gdprType: 2, | ||
name: 'functionality' | ||
}, | ||
{ | ||
defaultValue: false, | ||
description: 'These trackers help us to measure traffic and analyze your behavior to improve our service.', | ||
display: false, | ||
gdprType: 4, | ||
name: 'measurement' | ||
}, | ||
{ | ||
defaultValue: false, | ||
description: 'These trackers help us to improve the quality of your user experience and enable interactions with external content, networks, and platforms.', | ||
display: false, | ||
gdprType: 3, | ||
name: 'experience' | ||
}, | ||
{ | ||
defaultValue: false, | ||
description: 'These trackers help us to deliver personalized ads or marketing content to you, and to measure their performance.', | ||
display: false, | ||
gdprType: 5, | ||
name: 'marketing' | ||
} | ||
]; | ||
export { consentTypes }; |
@@ -36,18 +36,4 @@ /** | ||
*/ | ||
import type { | ||
ComplianceRegion, | ||
ComplianceSettings, | ||
ConsentState, | ||
HasConsentedProps, | ||
NamespaceProps, | ||
PrivacySettings, | ||
} from './compliance'; | ||
export type { | ||
ConsentState, | ||
ComplianceRegion, | ||
ComplianceSettings, | ||
PrivacySettings, | ||
HasConsentedProps, | ||
NamespaceProps, | ||
}; | ||
import type { ComplianceRegion, ComplianceSettings, ConsentBannerResponse, ConsentState, HasConsentedProps, JurisdictionInfo, LocationInfo, NamespaceProps, PrivacySettings } from './compliance'; | ||
export type { ConsentState, ComplianceRegion, ComplianceSettings, JurisdictionInfo, LocationInfo, ConsentBannerResponse, PrivacySettings, HasConsentedProps, NamespaceProps, }; | ||
/** | ||
@@ -133,11 +119,3 @@ * @module | ||
*/ | ||
export type { | ||
ConsentManagerDialogTranslations, | ||
ConsentManagerWidgetTranslations, | ||
ConsentTypeTranslations, | ||
ConsentTypesTranslations, | ||
CookieBannerTranslations, | ||
TranslationConfig, | ||
Translations, | ||
} from './translations'; | ||
//# sourceMappingURL=index.d.ts.map | ||
export type { ConsentManagerDialogTranslations, ConsentManagerWidgetTranslations, ConsentTypeTranslations, ConsentTypesTranslations, CookieBannerTranslations, TranslationConfig, Translations, } from './translations'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,4 +0,3 @@ | ||
import * as __WEBPACK_EXTERNAL_MODULE__gdpr_js_09f2378e__ from './gdpr.js'; | ||
var __webpack_exports__consentTypes = | ||
__WEBPACK_EXTERNAL_MODULE__gdpr_js_09f2378e__.consentTypes; | ||
import * as __WEBPACK_EXTERNAL_MODULE__gdpr_js_09f2378e__ from "./gdpr.js"; | ||
var __webpack_exports__consentTypes = __WEBPACK_EXTERNAL_MODULE__gdpr_js_09f2378e__.consentTypes; | ||
export { __webpack_exports__consentTypes as consentTypes }; |
import type { ConsentType } from './gdpr'; | ||
export interface CookieBannerTranslations { | ||
title: string; | ||
description: string; | ||
acceptAll: string; | ||
rejectAll: string; | ||
customize: string; | ||
title: string; | ||
description: string; | ||
acceptAll: string; | ||
rejectAll: string; | ||
customize: string; | ||
} | ||
export interface ConsentManagerDialogTranslations { | ||
title: string; | ||
description: string; | ||
save: string; | ||
acceptAll: string; | ||
rejectAll: string; | ||
close: string; | ||
title: string; | ||
description: string; | ||
save: string; | ||
acceptAll: string; | ||
rejectAll: string; | ||
close: string; | ||
} | ||
export interface ConsentTypeTranslations { | ||
title: string; | ||
description: string; | ||
title: string; | ||
description: string; | ||
} | ||
export interface ConsentManagerWidgetTranslations { | ||
title: string; | ||
description: string; | ||
save: string; | ||
acceptAll: string; | ||
rejectAll: string; | ||
title: string; | ||
description: string; | ||
save: string; | ||
acceptAll: string; | ||
rejectAll: string; | ||
} | ||
@@ -33,21 +33,21 @@ /** | ||
export type ConsentTypesTranslations = { | ||
[key in ConsentType['name']]: ConsentTypeTranslations; | ||
[key in ConsentType['name']]: ConsentTypeTranslations; | ||
}; | ||
export interface CompleteTranslations { | ||
cookieBanner: CookieBannerTranslations; | ||
consentManagerDialog: ConsentManagerDialogTranslations; | ||
consentManagerWidget: ConsentManagerWidgetTranslations; | ||
consentTypes: ConsentTypesTranslations; | ||
cookieBanner: CookieBannerTranslations; | ||
consentManagerDialog: ConsentManagerDialogTranslations; | ||
consentManagerWidget: ConsentManagerWidgetTranslations; | ||
consentTypes: ConsentTypesTranslations; | ||
} | ||
export interface Translations { | ||
cookieBanner: Partial<CookieBannerTranslations>; | ||
consentManagerDialog: Partial<ConsentManagerDialogTranslations>; | ||
consentManagerWidget: Partial<ConsentManagerWidgetTranslations>; | ||
consentTypes: Partial<ConsentTypesTranslations>; | ||
cookieBanner: Partial<CookieBannerTranslations>; | ||
consentManagerDialog: Partial<ConsentManagerDialogTranslations>; | ||
consentManagerWidget: Partial<ConsentManagerWidgetTranslations>; | ||
consentTypes: Partial<ConsentTypesTranslations>; | ||
} | ||
export interface TranslationConfig { | ||
translations: Record<string, Partial<Translations>>; | ||
defaultLanguage?: string; | ||
disableAutoLanguageSwitch?: boolean; | ||
translations: Record<string, Partial<Translations>>; | ||
defaultLanguage?: string; | ||
disableAutoLanguageSwitch?: boolean; | ||
} | ||
//# sourceMappingURL=translations.d.ts.map | ||
//# sourceMappingURL=translations.d.ts.map |
{ | ||
"name": "c15t", | ||
"version": "0.0.1-rc.9", | ||
"version": "0.0.1-rc.10", | ||
"license": "GPL-3.0-only", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
180851
69
3307
32