36 lines
828 B
JavaScript
36 lines
828 B
JavaScript
import { DEFAULT_STORAGE_KEY } from "./constants.js";
|
|
|
|
const DEFAULTS = {
|
|
storageKey: DEFAULT_STORAGE_KEY,
|
|
waitForUpdateMs: 500,
|
|
adsDataRedaction: true,
|
|
urlPassthrough: true,
|
|
regionDefaults: [],
|
|
debug: false,
|
|
};
|
|
|
|
let activeConfig = { ...DEFAULTS };
|
|
|
|
/**
|
|
* Configure global behaviour. Call once at app startup, before ConsentBootstrap.
|
|
* @param {import('./types.js').ConsentConfig} userConfig
|
|
*/
|
|
export function configureConsent(userConfig = {}) {
|
|
activeConfig = {
|
|
...DEFAULTS,
|
|
...userConfig,
|
|
regionDefaults: Array.isArray(userConfig.regionDefaults) ? userConfig.regionDefaults : [],
|
|
};
|
|
return getConsentConfig();
|
|
}
|
|
|
|
export function getConsentConfig() {
|
|
return { ...activeConfig };
|
|
}
|
|
|
|
export function getStorageKey() {
|
|
return activeConfig.storageKey;
|
|
}
|
|
|
|
export { DEFAULTS as defaultConfig };
|