Skip to content

Commit

Permalink
Merge pull request #14 from snackpass/feature/manually-place-fidesjs
Browse files Browse the repository at this point in the history
manually place fidesjs
  • Loading branch information
spacesean authored Apr 12, 2024
2 parents 2a99070 + 062a724 commit 19bd1b2
Show file tree
Hide file tree
Showing 2 changed files with 5,255 additions and 21 deletions.
55 changes: 34 additions & 21 deletions clients/privacy-center/pages/api/fides-js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export default async function handler(
);
}

console.log({ current_path: process.cwd(), fidesConfig });
console.log({ current_path: process.cwd() });

try {
const centerContents = await fsPromises.readdir(
Expand All @@ -196,16 +196,9 @@ export default async function handler(
console.log({ centerE: e });
}

try {
const taskContents = await fsPromises.readdir("/var/task/");
console.log({ task: taskContents });
} catch (e) {
console.log({ centerE: e });
}

const fidesJsFile = tcfEnabled
? "/var/task/privacy-center/.next/fides-tcf.js"
: "/var/task/privacy-center/.next/fides.js";
: "/var/task/privacy-center/.next/libfides.js";

try {
await fsPromises.readFile(fidesJsFile);
Expand All @@ -223,7 +216,7 @@ export default async function handler(
console.log({ message: "Loaded latest fides.js from server" });

/* eslint-disable @typescript-eslint/no-use-before-define */
const customFidesCss = await fetchCustomFidesCss(req);
// const customFidesCss = await fetchCustomFidesCss(req);

const script = `
(function () {
Expand All @@ -235,18 +228,38 @@ export default async function handler(
}
// Include generic fides.js script
${fidesJS}${
customFidesCss
? `
// Include custom fides.css styles
const style = document.createElement('style');
style.innerHTML = ${JSON.stringify(customFidesCss)};
document.head.append(style);
`
: ""
}
${fidesJS}
// Initialize fides.js with custom config
var fidesConfig = ${fidesConfigJSON};
var fidesConfig = {
consent: { options: [Array] },
options: {
debug: false,
geolocationApiUrl: 'https://cdn-api.ethyca.com/location',
isGeolocationEnabled: true,
isOverlayEnabled: true,
isPrefetchEnabled: true,
overlayParentId: null,
modalLinkId: null,
privacyCenterUrl: 'http://localhost:3000',
fidesApiUrl: 'https://brandeis.snackpass.co/api/v1',
tcfEnabled: false,
serverSideFidesApiUrl: 'https://brandeis.snackpass.co/api/v1',
fidesEmbed: false,
fidesDisableSaveApi: false,
fidesDisableBanner: false,
fidesTcfGdprApplies: true,
fidesString: null,
apiOptions: null,
fidesJsBaseUrl: 'http://localhost:3000',
customOptionsPath: null,
preventDismissal: false,
allowHTMLDescription: null,
base64Cookie: false,
fidesPrimaryColor: null
},
experience: undefined,
geolocation: undefined
};
window.Fides.init(fidesConfig);
})();
`;
Expand Down
Loading

0 comments on commit 19bd1b2

Please sign in to comment.