Skip to content

Commit

Permalink
GPP JS integration POC
Browse files Browse the repository at this point in the history
  • Loading branch information
erosselli committed Jan 28, 2025
1 parent 0f218f3 commit 43d0c1a
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ##
###################
Expand Down
11 changes: 11 additions & 0 deletions src/fides/gpp-js-integration-poc/README.md
Original file line number Diff line number Diff line change
@@ -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` .
21 changes: 21 additions & 0 deletions src/fides/gpp-js-integration-poc/gpp-helpers.py
Original file line number Diff line number Diff line change
@@ -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()
16 changes: 16 additions & 0 deletions src/fides/gpp-js-integration-poc/gpp-poc.js
Original file line number Diff line number Diff line change
@@ -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
};
46 changes: 46 additions & 0 deletions src/fides/gpp-js-integration-poc/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions src/fides/gpp-js-integration-poc/package.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]"
}

0 comments on commit 43d0c1a

Please sign in to comment.