diff --git a/.dockerignore b/.dockerignore index 0f311a452b..edb2196d8f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -17,6 +17,9 @@ src/ui-build/ **/npm-debug.log **/*__mocks__ +# Don't ignore GPP POC node_modules +src/fides/gpp-js-integration-poc/node_modules + # Ignore Python-Specific Files **/.mypy_cache/ **/.nox/ diff --git a/Dockerfile b/Dockerfile index a30d676191..7ddeee05cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -107,6 +107,25 @@ RUN pip install -e . --no-deps USER fidesuser +# Install Node Version Manager and Node v22 -- GPP POC +ENV NODE_VERSION=22.13.0 +RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash +ENV NVM_DIR="/home/fidesuser/.nvm" +RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION} +RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION} +RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION} +ENV PATH="${NVM_DIR}/versions/node/v${NODE_VERSION}/bin/:${PATH}" + +# Ser working directory to GPP POC and install JS dependencies +WORKDIR /fides/src/fides/gpp-js-integration-poc +RUN ls +RUN npm install +RUN ls + +# Set working directory back to Fides +WORKDIR /fides + + ################### ## Frontend Base ## ################### diff --git a/src/fides/gpp-js-integration-poc/README.md b/src/fides/gpp-js-integration-poc/README.md new file mode 100644 index 0000000000..f85c059300 --- /dev/null +++ b/src/fides/gpp-js-integration-poc/README.md @@ -0,0 +1,11 @@ +# GPP Integration POC + +This is a POC to establish the viability of running a JS script to interact with the IAB GPP JS library, and call this Javascript script from a Python function. + +## Running the POC + +Run the fides backend as usual: `nox -s dev -- shell`. + +In the fides container, go to the `gpp-js-integration-poc` folder: `cd gpp-js-integration-poc`. + +Run the python script: `python gpp-helpers.py` . diff --git a/src/fides/gpp-js-integration-poc/gpp-helpers.py b/src/fides/gpp-js-integration-poc/gpp-helpers.py new file mode 100644 index 0000000000..ca960f81a7 --- /dev/null +++ b/src/fides/gpp-js-integration-poc/gpp-helpers.py @@ -0,0 +1,21 @@ +import subprocess + +from fides.api.db.base import * +from fides.api.models.privacy_experience import PrivacyExperience +from fides.api.api.deps import get_db_contextmanager as get_db + + +def run_gpp_poc(): + print("RUNNING NODE POC...") + + with get_db() as db: + privacy_experience = db.query(PrivacyExperience).first() + print("PRIVACY EXPERIENCE: ", privacy_experience) + + result = subprocess.run(["npm", "run", "poc"], stdout=subprocess.PIPE) + print("NODE POC FINISHED: ", result) + print("STDOUT: ", result.stdout) + + +if __name__ == "__main__": + run_gpp_poc() diff --git a/src/fides/gpp-js-integration-poc/gpp-poc.js b/src/fides/gpp-js-integration-poc/gpp-poc.js new file mode 100644 index 0000000000..4d9a496417 --- /dev/null +++ b/src/fides/gpp-js-integration-poc/gpp-poc.js @@ -0,0 +1,16 @@ +const { GppModel } = require('@iabgpp/cmpapi'); + +/** CMP ID assigned to us by the IAB */ +const ETHYCA_CMP_ID = 407; + +const testCallCmpApi = () => { + // const cmpApi = new CmpApi(ETHYCA_CMP_ID, 1); + console.log("TEST"); + const model = new GppModel(); + console.log("model", model); + +} + +module.exports = { + testCallCmpApi +}; diff --git a/src/fides/gpp-js-integration-poc/package-lock.json b/src/fides/gpp-js-integration-poc/package-lock.json new file mode 100644 index 0000000000..88be66f93c --- /dev/null +++ b/src/fides/gpp-js-integration-poc/package-lock.json @@ -0,0 +1,46 @@ +{ + "name": "gpp-poc", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "gpp-poc", + "dependencies": { + "@iabgpp/cmpapi": "^3.1.4", + "@iabgpp/stub": "^3.1.5" + }, + "devDependencies": { + "@types/node": "22.10.7" + } + }, + "node_modules/@iabgpp/cmpapi": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/@iabgpp/cmpapi/-/cmpapi-3.1.5.tgz", + "integrity": "sha512-3TDr/mbZi5HHwOe4DJfbzKOjx8Jle8LWo4Hq8uD5JUc5S2VUEveYjOVcHDVz3+PyhvAnjUs6x27psT6PWaHRng==", + "license": "Apache-2.0" + }, + "node_modules/@iabgpp/stub": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/@iabgpp/stub/-/stub-3.1.5.tgz", + "integrity": "sha512-hPpJmARVjtMYLuOmegrqKxD6L+d9teTKwzG4XQYr6C0nDFpKnSyzZXDbQUn318d3WFY+1yh90CF+RuKRR7ps2w==", + "license": "Apache-2.0" + }, + "node_modules/@types/node": { + "version": "22.10.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.7.tgz", + "integrity": "sha512-V09KvXxFiutGp6B7XkpaDXlNadZxrzajcY50EuoLIpQ6WWYCSvf19lVIazzfIzQvhUN2HjX12spLojTnhuKlGg==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.20.0" + } + }, + "node_modules/undici-types": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", + "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==", + "dev": true, + "license": "MIT" + } + } +} diff --git a/src/fides/gpp-js-integration-poc/package.json b/src/fides/gpp-js-integration-poc/package.json new file mode 100644 index 0000000000..0bfa41025d --- /dev/null +++ b/src/fides/gpp-js-integration-poc/package.json @@ -0,0 +1,17 @@ +{ + "name": "gpp-poc", + "private": true, + "type": "commonjs", + "scripts": { + "poc": "node -e 'require(\"./gpp-poc.js\").testCallCmpApi()'", + "poc2": "node gpp-poc.js" + }, + "devDependencies": { + "@types/node": "22.10.7" + }, + "dependencies": { + "@iabgpp/cmpapi": "^3.1.4", + "@iabgpp/stub": "^3.1.5" + }, + "packageManager": "npm@10.8.3" +}