Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update deployment docs & run fmt #199

Merged
merged 5 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,32 @@
## v1.2 (2023/11/16)

#### Enhancements

- Home Site : upgrade CMS to [Docusaurus v3](https://docusaurus.io/blog/releases/3.0)
- DSP Site : serve attestation file version2 on privacy-sandbox-demos-dsp.dev
- SSP Site : serve attestation file version2 on privacy-sandbox-demos-ssp.dev
- CI/CD : Cloud Build copies the attestation files from cicd/attestations to dsp/ssp services for the target environment
- Update deployment documentation with instructions related to enrollment and attestation
- Use Case : Single-touch conversion Attribution. Move attribution code from SSP to DSP and update documentation
- Tools : Add [Aggregatable Report Converter](https://github.com/privacysandbox/privacy-sandbox-demos/tree/main/tools/aggregatable_report_converter) to the tooling codebase. This tool helps developers to create debug aggregatable reports that can be used for Local Testing and AWS Aggregation Service testing.
- GitHub documentation : Add a changelog


#### Bug Fixes


---

## v1.1 (2023/10/13)

#### Enhancements
- Shop site : refactor service using expressJS (from nextJS)

- Shop site : refactor service using expressJS (from nextJS)
- Shop site : fix issue with Firebase filtering session cookies
- DSP Site : attestation file is served from privacy-sandbox-demos-dsp.dev
- Use Case : remarketing. Move `renderURL` from the SSP codebase to the DSP codebase.
- Use Case : VAST Video Protected Audience. Release v1.


#### Bug Fixes

- Use Case : Single-touch conversion Attribution. Fix registering attribution sources ("Attribution-Reporting-Eligible" is a Dictionary Structured Header and thus need to be decoded accordingly)
- Home site : fix Docusaurus and nginx configuration that prevented direct links to use cases.
- Home site : fix broken links in documentation
Expand All @@ -36,6 +37,7 @@
---

## v1.0.0 (2023/06/30)

- Launch Privacy Sandbox Demos [Github Repository](https://github.com/privacysandbox/privacy-sandbox-demos)
- Launch hosted demos [https://privacy-sandbox-demos.dev/ ](https://privacy-sandbox-demos.dev/)
- Publication of a [blog post ](https://developer.chrome.com/blog/privacy-sandbox-demos/)on [developers.chrome.com](http://developers.chrome.com/)
30 changes: 21 additions & 9 deletions docs/deploy-to-gcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ If you don’t have yet a billing account, follow the documentation to Create a
3. Since you enabled Billing Account on this project, it will automatically select the Firebase pay-as-you-go plan
4. Enable Google Analytics for the project : Select "Default Account for Firebase" unless you have specific analytics requirements
3. If you don’t have the project owner role , you will need to obtain at least the following IAM role to your account on the target project before you proceed with the next steps.
1. Cloud Build Editor
2. Cloud Run Admin
3. Firebase Hosting Admin
4. Service Account User
5. Service Usage Consumer
6. Storage Admin
7. Storage Object Creator
8. Project Viewer
1. Artifact Registry Administrator
2. Cloud Build Editor
3. Cloud Run Admin
4. Firebase Hosting Admin
5. Service Account User
6. Service Usage Admin
7. Service Usage Consumer
8. Storage Admin
9. Storage Object Creator
10. Project Viewer

## Prepare your Development Environment for Firebase Hosting

Expand Down Expand Up @@ -213,6 +215,7 @@ gcloud auth configure-docker us-central1-docker.pkg.dev

Enable Vulnerability Scanning : navigate to settings and Turn On.
https://console.cloud.google.com/artifacts/settings

## Setup Cloud Build

https://cloud.google.com/build/docs/deploying-builds/deploy-cloud-run
Expand All @@ -229,7 +232,7 @@ https://console.cloud.google.com/iam-admin/iam

## Deploy all Cloud Run services and Firebase Sites

Once you have confirmed you can deploy a sample demo application on Cloud Run and access it from Firebase hosting site, you are ready to deploy all the services and hosting sites.
You are ready to deploy all the services and hosting sites.

Edit `cicd/.env.prod` file to match the `${SERVICE}_HOST` parameter to your firebase hosting domain e.g. : `privacy-sandbox-demos-${SERVICE}.dev`

Expand Down Expand Up @@ -263,6 +266,15 @@ GCP_PROJECT_NAME=xxx
FIREBASE_HOSTING_DOMAIN=**_privacy-sandbox-demos_**
```

**[optional]** If you have enrolled your site with Privacy Sandbox, copy your attestation files for dsp/ssp services under the folder : `cicd/attestations`

| Environment | Service | Attestation file name |
| :---------: | :-----: | :----------------------------------------: |
| prod | dsp | privacy-sandbox-attestations.json.dsp.prod |
| prod | ssp | privacy-sandbox-attestations.json.ssp.prod |
| dev | dsp | privacy-sandbox-attestations.json.dsp.dev |
| dev | ssp | privacy-sandbox-attestations.json.ssp.dev |

Execute `./scripts/cloudrun_deploy.sh` to build and deploy services with Cloud Build and deploy to Cloud Run.

Execute `./scripts/firebase_deploy.sh` to deploy Firebase hosting sites and configuration.
Expand Down
16 changes: 16 additions & 0 deletions docs/deploy-to-linux-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,22 @@ Run the command below _with your current user (not root !)_ to create the develo
mkcert -install
```

### Enrollment & Attestation exception

To access the Privacy Sandbox relevance and measurement APIs on Chrome, developers need to [enroll their site](https://github.com/privacysandbox/attestation/blob/main/how-to-enroll.md) with the Privacy Sandbox, pass the verification process, and upload an attestation file on their site.

However you do not need to enroll if you are only testing with local traffic. For local testing, Chrome provides [a flag and CLI switch](https://github.com/privacysandbox/attestation/blob/main/how-to-enroll.md#5-do-i-need-to-enroll-to-test-against-local-development-environments) to bypass enrollment on your local browser.

Open `chrome://flags/#privacy-sandbox-enrollment-overrides`

Under `Privacy Sandbox Enrollment Overrides` select `Enabled` and enter your site domain names separated by a coma :

Example :

```shell
https://privacy-sandbox-demos-dsp.dev,https://privacy-sandbox-demos-ssp.dev
```

## Build & Run your local development environment

### Clone the Privacy Sandbox Demos repository
Expand Down
27 changes: 11 additions & 16 deletions services/dsp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ app.use((req, res, next) => {
next()
})

app.use(express.urlencoded({extended: true}));
app.use(express.urlencoded({ extended: true }))
app.use(express.json()) // To parse the incoming requests with JSON payloads

app.use(
Expand Down Expand Up @@ -143,32 +143,27 @@ app.get("/bidding_signal.json", async (req: Request, res: Response) => {
// })

app.post("/.well-known/private-aggregation/report-shared-storage", (req, res) => {
console.log(`Received Aggregatable Report on live endpoint`)

console.log( `Received Aggregatable Report on live endpoint`);

let aggregationReport = req.body;
console.log(req.body);

res.sendStatus(200);
let aggregationReport = req.body
console.log(req.body)

res.sendStatus(200)
})

app.get("/private-aggregation", (req, res) => {
res.render('private-aggregation');
res.render("private-aggregation")
})

app.post("/.well-known/private-aggregation/debug/report-shared-storage", (req, res) => {
let timeStr = new Date().toISOString()
console.log(`Received Aggregatable Report on debug endpoint`)

let timeStr = new Date().toISOString();
console.log( `Received Aggregatable Report on debug endpoint`);

let aggregationReport = req.body;

console.log(aggregationReport);

let aggregationReport = req.body

res.sendStatus(200);
console.log(aggregationReport)

res.sendStatus(200)
})

app.get("/", async (req: Request, res: Response) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
{
"attestation_parser_version": "2",
"attestation_version": "2",
"privacy_policy": [
"https://policies.google.com/privacy"
],
"privacy_policy": ["https://policies.google.com/privacy"],
"ownership_token": "SGYvJieJb5EaxhMAJUh9qmrfZNSQewLYbHWx6NpeRzDLZSF0DwfVfchu5sHCxaFv",
"issued_seconds_since_epoch": 1697505143,
"enrollment_id": "UNRJE",
Expand Down Expand Up @@ -40,9 +38,7 @@
{
"attestation_parser_version": "1",
"attestation_version": "1",
"privacy_policy": [
"https://policies.google.com/privacy"
],
"privacy_policy": ["https://policies.google.com/privacy"],
"ownership_token": "yE67UyEyxUmBsz0y0hyeiU44CnbliMjMS93fnBgeb8Jlst1YbwYXAE5ucVige0eX",
"issued_seconds_since_epoch": 1691175921,
"expiry_seconds_since_epoch": 1706731521,
Expand Down
12 changes: 6 additions & 6 deletions services/dsp/src/public/js/dsp.js
Seburan marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
let dsp = document.currentScript.getAttribute('dsp');
let dsp = document.currentScript.getAttribute("dsp")
window.addEventListener("load", (event) => {
let iframe = document.createElement('iframe');
// let dsp = document.currentScript.getAttribute('dsp');
iframe.src = `https://${dsp}/private-aggregation`;
document.body.appendChild(iframe);
});
let iframe = document.createElement("iframe")
// let dsp = document.currentScript.getAttribute('dsp');
iframe.src = `https://${dsp}/private-aggregation`
document.body.appendChild(iframe)
})
38 changes: 18 additions & 20 deletions services/dsp/src/public/js/private-aggregation-worklet.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
class TestPrivateAggregation {
async run(data){
console.log("Enabling Private Aggregation Debug Mode");
privateAggregation.enableDebugMode({debugKey: 1234n});
let campaignId = await sharedStorage.get('campaignId');
if(!campaignId) {
console.log("No campaign id found for client. Adding campaignId 1234567890.");
campaignId = "1234567890";
sharedStorage.set("campaignId", campaignId);
} else {
console.log(`Campaign ID found: ${campaignId}`);
}
function convertToBucket(bucketId){
return BigInt(bucketId);
}
const bucket = convertToBucket(campaignId);
const value = 128;
privateAggregation.contributeToHistogram({bucket, value});

async run(data) {
console.log("Enabling Private Aggregation Debug Mode")
privateAggregation.enableDebugMode({ debugKey: 1234n })
let campaignId = await sharedStorage.get("campaignId")
if (!campaignId) {
console.log("No campaign id found for client. Adding campaignId 1234567890.")
campaignId = "1234567890"
sharedStorage.set("campaignId", campaignId)
} else {
console.log(`Campaign ID found: ${campaignId}`)
}

function convertToBucket(bucketId) {
return BigInt(bucketId)
}
const bucket = convertToBucket(campaignId)
const value = 128
privateAggregation.contributeToHistogram({ bucket, value })
}
}

register("test-private-aggregation", TestPrivateAggregation);
register("test-private-aggregation", TestPrivateAggregation)
6 changes: 3 additions & 3 deletions services/dsp/src/public/js/private-aggregation.js
Seburan marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
async function runPrivateAggregation() {
await window.sharedStorage.worklet.addModule('js/private-aggregation-worklet.js');
await window.sharedStorage.run('test-private-aggregation');
await window.sharedStorage.worklet.addModule("js/private-aggregation-worklet.js")
await window.sharedStorage.run("test-private-aggregation")
}

runPrivateAggregation();
runPrivateAggregation()
4 changes: 2 additions & 2 deletions services/home/docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion

const lightCodeTheme = require("prism-react-renderer").themes.github;
const darkCodeTheme = require("prism-react-renderer").themes.dracula;
const lightCodeTheme = require("prism-react-renderer").themes.github
const darkCodeTheme = require("prism-react-renderer").themes.dracula

const host = process.env.HOME_HOST

Expand Down
14 changes: 9 additions & 5 deletions tools/aggregatable_report_converter/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
# Aggregatable Report Converter

## Purpose

To provide Aggregation Service testers tools to create debug aggregatable reports that can be used for Local Testing and AWS Aggregation Service testing.

## Guide

1. Clone the privacy-sandbox-demos repository.
2. Go to \<repository\>/tools/aggregatable_report_converter
3. Options for usage:
1. Use the jar file available in \<repository\>/tools/aggregatable_report_converter/out/artifacts/aggregatable_report_converter_jar.
2. Build jar file for the project `aggregatable_report_converter` using Eclipse or Intellij.

### Build your jar file in Intellij

1. Open Project in Intellij
2. Go to `Build` > `Build Project`.
3. Go to `File` > `Project Structure`. Select `Artifacts` under `Project Settings`.
4. Click `+` > `JAR` > `From modules with dependencies...`.
5. Ensure `module` selected is `aggregatable_report_converter`.
6. In Main Class, select `Main`. Click `OK` > `Apply`.


## How to use

Once the jar file is created, you can get options available for this tool using the command `java -jar aggregatable_report_converter.jar --help`.

To convert json reports to debug aggregatable reports, you can use the below command:

```angular2html
java -jar aggregatable_report_converter.jar \
--request_type convertToAvro \
Expand All @@ -32,6 +35,7 @@ java -jar aggregatable_report_converter.jar \
```

To create output domain avro file, you can use the below command:

```angular2html
java -jar aggregatable_report_converter.jar \
--request_type createDomainAvro \
Expand All @@ -42,20 +46,20 @@ java -jar aggregatable_report_converter.jar \

--request_type [request type] \
Type of request. Options available:

- convertToAvro: converts a json report to an avro aggregatable report
- convertToJson: converts the avro summary report to a json report
- createDomainAvro: creates an output_domain.avro file from provided bucket key

--input_file [file name] \
This will be the file that will be encoded.
This will be the file that will be encoded.

--debug \
This will signify that the request is for debug. \
If the type of request is convertToAvro, this will create a debug avro report for local testing.
This will signify that the request is for debug. \
If the type of request is convertToAvro, this will create a debug avro report for local testing.

--bucket_key [bucket key] \
Provide your bucket key here.

--output_file [file name] \
Output filename the report will be written to.

Loading