diff --git a/attribution-reporting/.firebaserc b/attribution-reporting/.firebaserc new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/attribution-reporting/.firebaserc @@ -0,0 +1 @@ +{} diff --git a/attribution-reporting/README.md b/attribution-reporting/README.md index 763d865..f17fc0f 100644 --- a/attribution-reporting/README.md +++ b/attribution-reporting/README.md @@ -6,7 +6,7 @@ ### Set up (one time only) 1. If it's not yet installed on your machine, install [node.js](https://nodejs.org/en/download/). -2. Install the latest Firebase CLI by running the following in your terminal: `npm install -g firebase-tools`. +2. Install the latest Firebase CLI by running the following in your terminal: `npm install -g firebase-tools`. The version known to work with this README.md is 13.3.0. 3. In your terminal, run `git clone https://github.com/GoogleChromeLabs/trust-safety-demo.git && cd trust-safety-demo/attribution-reporting`. This command will create a folder, clone all of the `trust-safety` demo code in that folder, and navigate you to the `attribution-reporting` demo subfolder. 4. In your terminal, run `cd functions && npm install && cd ..`. This command will install all the required dependencies for you to locally run the `attribution-reporting` demo. diff --git a/attribution-reporting/firebase.json b/attribution-reporting/firebase.json index 63417a4..bc92995 100644 --- a/attribution-reporting/firebase.json +++ b/attribution-reporting/firebase.json @@ -1,5 +1,6 @@ { - "hosting": [{ + "hosting": [ + { "site": "arapi-home", "public": "sites/home", "ignore": [ @@ -7,10 +8,12 @@ "**/.*", "**/node_modules/**" ], - "rewrites": [{ - "source": "**", - "function": "home" - }] + "rewrites": [ + { + "source": "**", + "function": "home" + } + ] }, { "site": "arapi-adtech", @@ -20,7 +23,8 @@ "**/.*", "**/node_modules/**" ], - "rewrites": [{ + "rewrites": [ + { "source": "**", "function": "adtech" }, @@ -38,10 +42,12 @@ "**/.*", "**/node_modules/**" ], - "rewrites": [{ - "source": "**", - "function": "advertiser" - }] + "rewrites": [ + { + "source": "**", + "function": "advertiser" + } + ] }, { "site": "arapi-publisher", @@ -51,10 +57,12 @@ "**/.*", "**/node_modules/**" ], - "rewrites": [{ - "source": "**", - "function": "publisher" - }] + "rewrites": [ + { + "source": "**", + "function": "publisher" + } + ] } ], "emulators": { @@ -65,5 +73,17 @@ "host": "localhost", "port": "8080" } - } -} \ No newline at end of file + }, + "functions": [ + { + "source": "functions", + "codebase": "default", + "ignore": [ + "node_modules", + ".git", + "firebase-debug.log", + "firebase-debug.*.log" + ] + } + ] +} diff --git a/attribution-reporting/functions/.gitignore b/attribution-reporting/functions/.gitignore new file mode 100644 index 0000000..40b878d --- /dev/null +++ b/attribution-reporting/functions/.gitignore @@ -0,0 +1 @@ +node_modules/ \ No newline at end of file diff --git a/attribution-reporting/functions/apps/adtech.js b/attribution-reporting/functions/apps/adtech.js index 1b82c27..adc8f84 100644 --- a/attribution-reporting/functions/apps/adtech.js +++ b/attribution-reporting/functions/apps/adtech.js @@ -171,12 +171,15 @@ adtech.get( res.set('Attribution-Reporting-Register-Source', JSON.stringify(headerConfig)) log('REGISTERING SOURCE \n', headerConfig) - if (req.originalUrl === '/register-source-image') { + const urlParts = req.originalUrl.split('/') + const url = urlParts[urlParts.length - 1] + + if (url === 'register-source-image') { // Send back the response res.status(200).sendFile('blue-shoes.png', { root: path.join(__dirname, '../../sites/adtech') }) - } else if (['/register-source-href', '/register-source-js'].includes(req.originalUrl)) { + } else if (['register-source-href', 'register-source-js'].includes(url)) { res.redirect(advertiserUrl) } }) diff --git a/attribution-reporting/functions/package.json b/attribution-reporting/functions/package.json index cfb02f1..53ec609 100644 --- a/attribution-reporting/functions/package.json +++ b/attribution-reporting/functions/package.json @@ -9,7 +9,7 @@ "logs": "firebase functions:log" }, "engines": { - "node": "14" + "node": "20" }, "repository": { "type": "git" diff --git a/attribution-reporting/functions/views/home/index.pug b/attribution-reporting/functions/views/home/index.pug index 4822302..1d29608 100644 --- a/attribution-reporting/functions/views/home/index.pug +++ b/attribution-reporting/functions/views/home/index.pug @@ -49,10 +49,10 @@ body li Visit span.code.select chrome://flags/#privacy-sandbox-enrollment-overrides | and add - span.code.select https://arapi-adtech.web.app + span.code.select #{adtechUrl} | in the text box li Start Chrome from the command line with - span.code.select --privacy-sandbox-enrollment-overrides=https://arapi-adtech.web.app + span.code.select --privacy-sandbox-enrollment-overrides=#{adtechUrl} li See the a(href="https://github.com/privacysandbox/attestation/blob/main/how-to-enroll.md#5-do-i-need-to-enroll-to-test-against-local-development-environments" noreferrer noopener target="_blank") explainer | to learn more