diff --git a/clients/fides-js/docs/interfaces/FidesOptions.md b/clients/fides-js/docs/interfaces/FidesOptions.md index a510a57997..f0e60f371f 100644 --- a/clients/fides-js/docs/interfaces/FidesOptions.md +++ b/clients/fides-js/docs/interfaces/FidesOptions.md @@ -1,7 +1,7 @@ # Interface: FidesOptions FidesJS supports a variety of custom options to modify it's behavior or -enabled more advanced usage. For example, the `fides_locale` option can be +enable more advanced usage. For example, the `fides_locale` option can be provided to override the browser locale. See the properties list below for the supported options and example usage for each. @@ -160,3 +160,17 @@ overriden at the page-level as needed. Only applicable to a TCF experience. For more details, see the [TCF CMP API technical specification](https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20CMP%20API%20v2.md#what-does-the-gdprapplies-value-mean) * Defaults to `true`. + +*** + +### fides\_reject\_all + +> **fides\_reject\_all**: `boolean` + +When `true`, FidesJS will automatically opt out of all consent and +only show the consent modal upon user request. This is useful for any +scenario where the user has previously provided consent in a different +context (e.g. a native app, another website, etc.) and you want to ensure +that those preferences are respected. + +Defaults to `false`. diff --git a/clients/fides-js/src/components/Overlay.tsx b/clients/fides-js/src/components/Overlay.tsx index 1e3036d798..b7ce1e9200 100644 --- a/clients/fides-js/src/components/Overlay.tsx +++ b/clients/fides-js/src/components/Overlay.tsx @@ -75,6 +75,7 @@ const Overlay: FunctionComponent = ({ const showBanner = useMemo( () => + !options.fidesRejectAll && !options.fidesDisableBanner && experience.experience_config?.component !== ComponentType.MODAL && shouldResurfaceConsent(experience, cookie, savedConsent), diff --git a/clients/fides-js/src/components/notices/NoticeOverlay.tsx b/clients/fides-js/src/components/notices/NoticeOverlay.tsx index 4f764f4a05..34231bbc36 100644 --- a/clients/fides-js/src/components/notices/NoticeOverlay.tsx +++ b/clients/fides-js/src/components/notices/NoticeOverlay.tsx @@ -229,6 +229,28 @@ const NoticeOverlay: FunctionComponent = ({ ], ); + useEffect(() => { + if ( + handleUpdatePreferences && + options.fidesRejectAll && + experience.privacy_notices + ) { + fidesDebugger( + "Consent automatically rejected by fides_reject_all override!", + ); + handleUpdatePreferences( + ConsentMethod.REJECT, + experience.privacy_notices + .filter((n) => n.consent_mechanism === ConsentMechanism.NOTICE_ONLY) + .map((n) => n.notice_key), + ); + } + }, [ + experience.privacy_notices, + handleUpdatePreferences, + options.fidesRejectAll, + ]); + const dispatchOpenBannerEvent = useCallback(() => { dispatchFidesEvent("FidesUIShown", cookie, options.debug, { servingComponent: ServingComponent.BANNER, diff --git a/clients/fides-js/src/components/tcf/TcfConsentButtons.tsx b/clients/fides-js/src/components/tcf/TcfConsentButtons.tsx index eeaf2e83dc..d58a21b7fb 100644 --- a/clients/fides-js/src/components/tcf/TcfConsentButtons.tsx +++ b/clients/fides-js/src/components/tcf/TcfConsentButtons.tsx @@ -6,6 +6,7 @@ import { PrivacyExperience, PrivacyExperienceMinimal, } from "../../lib/consent-types"; +import { EMPTY_ENABLED_IDS } from "../../lib/tcf/constants"; import type { EnabledIds, TcfModels } from "../../lib/tcf/types"; import { ConsentButtons } from "../ConsentButtons"; @@ -87,15 +88,7 @@ export const TcfConsentButtons = ({ onSave(ConsentMethod.ACCEPT, allIds); }; const handleRejectAll = () => { - const emptyIds: EnabledIds = { - purposesConsent: [], - purposesLegint: [], - specialPurposes: [], - features: [], - specialFeatures: [], - vendorsConsent: [], - vendorsLegint: [], - }; + const emptyIds: EnabledIds = EMPTY_ENABLED_IDS; onSave(ConsentMethod.REJECT, emptyIds); }; diff --git a/clients/fides-js/src/components/tcf/TcfOverlay.tsx b/clients/fides-js/src/components/tcf/TcfOverlay.tsx index ca7036c730..9e6d60c99c 100644 --- a/clients/fides-js/src/components/tcf/TcfOverlay.tsx +++ b/clients/fides-js/src/components/tcf/TcfOverlay.tsx @@ -25,6 +25,7 @@ import { } from "../../lib/i18n"; import { useI18n } from "../../lib/i18n/i18n-context"; import { updateConsentPreferences } from "../../lib/preferences"; +import { EMPTY_ENABLED_IDS } from "../../lib/tcf/constants"; import { useGvl } from "../../lib/tcf/gvl-context"; import type { EnabledIds, TcfSavePreferences } from "../../lib/tcf/types"; import { @@ -163,15 +164,7 @@ export const TcfOverlay = ({ useEffect(() => { if (!experience) { - setDraftIds({ - purposesConsent: [], - purposesLegint: [], - specialPurposes: [], - features: [], - specialFeatures: [], - vendorsConsent: [], - vendorsLegint: [], - }); + setDraftIds(EMPTY_ENABLED_IDS); } else { const { tcf_purpose_consents: consentPurposes = [], @@ -293,6 +286,15 @@ export const TcfOverlay = ({ ], ); + useEffect(() => { + if (options.fidesRejectAll) { + fidesDebugger( + "Consent automatically rejected by fides_reject_all override!", + ); + handleUpdateAllPreferences(ConsentMethod.REJECT, EMPTY_ENABLED_IDS); + } + }, [handleUpdateAllPreferences, options.fidesRejectAll]); + const [activeTabIndex, setActiveTabIndex] = useState(0); const dispatchOpenBannerEvent = useCallback(() => { diff --git a/clients/fides-js/src/docs/fides-options.ts b/clients/fides-js/src/docs/fides-options.ts index 9fbd199810..fe4c376056 100644 --- a/clients/fides-js/src/docs/fides-options.ts +++ b/clients/fides-js/src/docs/fides-options.ts @@ -1,6 +1,6 @@ /** * FidesJS supports a variety of custom options to modify it's behavior or - * enabled more advanced usage. For example, the `fides_locale` option can be + * enable more advanced usage. For example, the `fides_locale` option can be * provided to override the browser locale. See the properties list below for * the supported options and example usage for each. * @@ -143,4 +143,15 @@ export interface FidesOptions { * Defaults to `true`. */ fides_tcf_gdpr_applies: boolean; + + /** + * When `true`, FidesJS will automatically opt out of all consent and + * only show the consent modal upon user request. This is useful for any + * scenario where the user has previously provided consent in a different + * context (e.g. a native app, another website, etc.) and you want to ensure + * that those preferences are respected. + * + * Defaults to `false`. + */ + fides_reject_all: boolean; } diff --git a/clients/fides-js/src/fides-tcf.ts b/clients/fides-js/src/fides-tcf.ts index 0e522f42c7..2e215a6757 100644 --- a/clients/fides-js/src/fides-tcf.ts +++ b/clients/fides-js/src/fides-tcf.ts @@ -261,6 +261,7 @@ const _Fides: FidesGlobal = { fidesPrimaryColor: null, fidesClearCookie: false, showFidesBrandLink: false, + fidesRejectAll: false, }, fides_meta: {}, identity: {}, @@ -281,6 +282,10 @@ const _Fides: FidesGlobal = { // Nothing to show if there's no experience return false; } + if (this.options.fidesRejectAll) { + // If automatically rejected, we should not show the experience + return false; + } if (!this.cookie) { throw new Error("Should have a cookie"); } diff --git a/clients/fides-js/src/fides.ts b/clients/fides-js/src/fides.ts index 919476d60a..5724b11508 100644 --- a/clients/fides-js/src/fides.ts +++ b/clients/fides-js/src/fides.ts @@ -201,6 +201,7 @@ const _Fides: FidesGlobal = { fidesPrimaryColor: null, fidesClearCookie: false, showFidesBrandLink: true, + fidesRejectAll: false, }, fides_meta: {}, identity: {}, @@ -223,6 +224,10 @@ const _Fides: FidesGlobal = { // Nothing to show if there's no experience return false; } + if (this.options.fidesRejectAll) { + // If automatically rejected, we should not show the experience + return false; + } if (!this.cookie) { throw new Error("Should have a cookie"); } diff --git a/clients/fides-js/src/lib/consent-constants.ts b/clients/fides-js/src/lib/consent-constants.ts index 6702771e79..79c44d82d8 100644 --- a/clients/fides-js/src/lib/consent-constants.ts +++ b/clients/fides-js/src/lib/consent-constants.ts @@ -85,6 +85,12 @@ export const FIDES_OVERRIDE_OPTIONS_VALIDATOR_MAP: { overrideKey: "fides_clear_cookie", validationRegex: /(.*)/, }, + { + overrideName: "fidesRejectAll", + overrideType: "boolean", + overrideKey: "fides_reject_all", + validationRegex: /^(true|false)$/, + }, ]; /** diff --git a/clients/fides-js/src/lib/consent-types.ts b/clients/fides-js/src/lib/consent-types.ts index 414198c55e..90d6b341d3 100644 --- a/clients/fides-js/src/lib/consent-types.ts +++ b/clients/fides-js/src/lib/consent-types.ts @@ -139,6 +139,9 @@ export interface FidesInitOptions { // Whether to render the brand link in the footer of the modal showFidesBrandLink: boolean; + + // Whether to reject all consent preferences by default + fidesRejectAll: boolean; } /** @@ -686,6 +689,7 @@ export type FidesInitOptionsOverrides = Pick< | "fidesLocale" | "fidesPrimaryColor" | "fidesClearCookie" + | "fidesRejectAll" >; export type FidesExperienceTranslationOverrides = { diff --git a/clients/fides-js/src/lib/tcf/constants.ts b/clients/fides-js/src/lib/tcf/constants.ts index b1ddd8a94f..05f2c350eb 100644 --- a/clients/fides-js/src/lib/tcf/constants.ts +++ b/clients/fides-js/src/lib/tcf/constants.ts @@ -93,3 +93,13 @@ export const LEGAL_BASIS_OPTIONS = [ value: LegalBasisEnum.LEGITIMATE_INTERESTS.toString(), }, ]; + +export const EMPTY_ENABLED_IDS: EnabledIds = { + purposesConsent: [], + purposesLegint: [], + specialPurposes: [], + features: [], + specialFeatures: [], + vendorsConsent: [], + vendorsLegint: [], +}; diff --git a/clients/privacy-center/app/server-environment.ts b/clients/privacy-center/app/server-environment.ts index f2d7ce30b5..58707ae65d 100644 --- a/clients/privacy-center/app/server-environment.ts +++ b/clients/privacy-center/app/server-environment.ts @@ -66,6 +66,7 @@ export type PrivacyCenterClientSettings = Pick< | "BASE_64_COOKIE" | "FIDES_PRIMARY_COLOR" | "FIDES_CLEAR_COOKIE" + | "FIDES_REJECT_ALL" >; export type Styles = string; @@ -352,6 +353,7 @@ export const loadPrivacyCenterEnvironment = async ({ BASE_64_COOKIE: settings.BASE_64_COOKIE, FIDES_PRIMARY_COLOR: settings.FIDES_PRIMARY_COLOR, FIDES_CLEAR_COOKIE: settings.FIDES_CLEAR_COOKIE, + FIDES_REJECT_ALL: settings.FIDES_REJECT_ALL, }; // For backwards-compatibility, override FIDES_API_URL with the value from the config file if present diff --git a/clients/privacy-center/app/server-utils/PrivacyCenterSettings.ts b/clients/privacy-center/app/server-utils/PrivacyCenterSettings.ts index 07ea8f6791..7928aa5645 100644 --- a/clients/privacy-center/app/server-utils/PrivacyCenterSettings.ts +++ b/clients/privacy-center/app/server-utils/PrivacyCenterSettings.ts @@ -38,4 +38,5 @@ export interface PrivacyCenterSettings { BASE_64_COOKIE: boolean; // whether or not to encode cookie as base64 on top of the default JSON string FIDES_PRIMARY_COLOR: string | null; // (optional) sets fides primary color FIDES_CLEAR_COOKIE: boolean; // (optional) deletes fides_consent cookie on reload + FIDES_REJECT_ALL: boolean; // (optional) rejects all consent preferences on load } diff --git a/clients/privacy-center/app/server-utils/loadEnvironmentVariables.ts b/clients/privacy-center/app/server-utils/loadEnvironmentVariables.ts index 5653ae1239..29cbec7107 100644 --- a/clients/privacy-center/app/server-utils/loadEnvironmentVariables.ts +++ b/clients/privacy-center/app/server-utils/loadEnvironmentVariables.ts @@ -85,6 +85,9 @@ const loadEnvironmentVariables = () => { FIDES_CLEAR_COOKIE: process.env.FIDES_PRIVACY_CENTER__FIDES_CLEAR_COOKIE ? process.env.FIDES_PRIVACY_CENTER__FIDES_CLEAR_COOKIE === "true" : false, + FIDES_REJECT_ALL: process.env.FIDES_PRIVACY_CENTER__FIDES_REJECT_ALL + ? process.env.FIDES_PRIVACY_CENTER__FIDES_REJECT_ALL === "true" + : false, }; return settings; }; diff --git a/clients/privacy-center/pages/api/fides-js.ts b/clients/privacy-center/pages/api/fides-js.ts index b3a91c391f..cda82deb24 100644 --- a/clients/privacy-center/pages/api/fides-js.ts +++ b/clients/privacy-center/pages/api/fides-js.ts @@ -262,6 +262,7 @@ export default async function handler( base64Cookie: environment.settings.BASE_64_COOKIE, fidesPrimaryColor: environment.settings.FIDES_PRIMARY_COLOR, fidesClearCookie: environment.settings.FIDES_CLEAR_COOKIE, + fidesRejectAll: environment.settings.FIDES_REJECT_ALL, }, experience: experience || undefined, geolocation: geolocation || undefined,