Skip to content

Commit

Permalink
add fides_reject_all override option
Browse files Browse the repository at this point in the history
  • Loading branch information
gilluminate committed Nov 25, 2024
1 parent ca2be22 commit 646ed68
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 1 deletion.
14 changes: 14 additions & 0 deletions clients/fides-js/docs/interfaces/FidesOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
11 changes: 11 additions & 0 deletions clients/fides-js/src/docs/fides-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions clients/fides-js/src/fides-tcf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ const _Fides: FidesGlobal = {
fidesPrimaryColor: null,
fidesClearCookie: false,
showFidesBrandLink: false,
fidesRejectAll: false,
},
fides_meta: {},
identity: {},
Expand Down
1 change: 1 addition & 0 deletions clients/fides-js/src/fides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ const _Fides: FidesGlobal = {
fidesPrimaryColor: null,
fidesClearCookie: false,
showFidesBrandLink: true,
fidesRejectAll: false,
},
fides_meta: {},
identity: {},
Expand Down
6 changes: 6 additions & 0 deletions clients/fides-js/src/lib/consent-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ export const FIDES_OVERRIDE_OPTIONS_VALIDATOR_MAP: {
overrideKey: "fides_clear_cookie",
validationRegex: /(.*)/,
},
{
overrideName: "fidesRejectAll",
overrideType: "string",
overrideKey: "fides_reject_all",
validationRegex: /(.*)/,
},
];

/**
Expand Down
4 changes: 4 additions & 0 deletions clients/fides-js/src/lib/consent-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -686,6 +689,7 @@ export type FidesInitOptionsOverrides = Pick<
| "fidesLocale"
| "fidesPrimaryColor"
| "fidesClearCookie"
| "fidesRejectAll"
>;

export type FidesExperienceTranslationOverrides = {
Expand Down
2 changes: 2 additions & 0 deletions clients/privacy-center/app/server-environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export type PrivacyCenterClientSettings = Pick<
| "BASE_64_COOKIE"
| "FIDES_PRIMARY_COLOR"
| "FIDES_CLEAR_COOKIE"
| "FIDES_REJECT_ALL"
>;

export type Styles = string;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
9 changes: 9 additions & 0 deletions clients/privacy-center/pages/api/fides-js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ let autoRefresh: boolean = true;
* description: When set to "false" fides.js will not be initialized automatically; use `window.Fides.init()` to initialize manually
* schema:
* type: boolean
* - in: query
* name: fides_reject_all
* required: false
* description: Automatically rejects all consent preferences when fides.js is initialized
* schema:
* type: boolean
* - in: header
* name: CloudFront-Viewer-Country
* required: false
Expand Down Expand Up @@ -262,6 +268,9 @@ 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 ||
req.query.fides_reject_all === "true",
},
experience: experience || undefined,
geolocation: geolocation || undefined,
Expand Down
5 changes: 4 additions & 1 deletion clients/sample-app/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const IndexPage = ({ gtmContainerId, privacyCenterUrl, products }: Props) => {
const fidesScriptTagUrl = new URL(`${privacyCenterUrl}/fides.js`);
const router = useRouter();
// eslint-disable-next-line @typescript-eslint/naming-convention
const { geolocation, property_id } = router.query;
const { geolocation, property_id, fides_reject_all } = router.query;

// If `geolocation=` or `property_id` query params exists, pass those along to the fides.js fetch
if (geolocation && typeof geolocation === "string") {
Expand All @@ -61,6 +61,9 @@ const IndexPage = ({ gtmContainerId, privacyCenterUrl, products }: Props) => {
if (typeof property_id === "string") {
fidesScriptTagUrl.searchParams.append("property_id", property_id);
}
if (typeof fides_reject_all === "string") {
fidesScriptTagUrl.searchParams.append("fides_reject_all", fides_reject_all);
}

return (
<>
Expand Down

0 comments on commit 646ed68

Please sign in to comment.