Skip to content

Commit

Permalink
Merge pull request #345 from maybellineboon/private-aggregation-cloud…
Browse files Browse the repository at this point in the history
…-update

Private aggregation cloud update -> please run test in Dev Environment
  • Loading branch information
Seburan authored Jun 12, 2024
2 parents 6951b06 + 7f346cf commit 3a96fcf
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 102 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3
with:
results_file: results.sarif
results_format: sarif
Expand Down
14 changes: 8 additions & 6 deletions services/dsp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,14 @@ app.post(
},
);

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

app.get('/private-aggregation-gcp', (req, res) => {
res.render('private-aggregation-gcp');
app.get('/private-aggregation', (req, res) => {
const bucket = req.query.bucket;
const cloudEnv = req.query.cloudEnv;
console.log(`${bucket}, ${cloudEnv}`);
res.render('private-aggregation', {
bucket: bucket,
cloudEnv: cloudEnv,
});
});

app.post(
Expand Down
14 changes: 7 additions & 7 deletions services/dsp/src/public/js/dsp.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
let dsp = document.currentScript.getAttribute('dsp');
let bucket = document.currentScript.getAttribute('bucket');
let cloudEnv = document.currentScript.getAttribute('cloudenv');
window.addEventListener('load', (event) => {
let iframeAws = document.createElement('iframe');
let iframeGcp = document.createElement('iframe');
// let dsp = document.currentScript.getAttribute('dsp');
iframeAws.src = `https://${dsp}/private-aggregation-aws`;
iframeGcp.src = `https://${dsp}/private-aggregation-gcp`;
document.body.appendChild(iframeAws);
document.body.appendChild(iframeGcp);
if (cloudEnv == 'aws' || cloudEnv == 'gcp') {
let iframe = document.createElement('iframe');
iframe.src = `https://${dsp}/private-aggregation?bucket=${bucket}&cloudEnv=${cloudEnv}`;
document.body.appendChild(iframe);
}
});
14 changes: 0 additions & 14 deletions services/dsp/src/public/js/private-aggregation-aws.js

This file was deleted.

14 changes: 0 additions & 14 deletions services/dsp/src/public/js/private-aggregation-gcp.js

This file was deleted.

24 changes: 0 additions & 24 deletions services/dsp/src/public/js/private-aggregation-worklet-aws.js

This file was deleted.

24 changes: 0 additions & 24 deletions services/dsp/src/public/js/private-aggregation-worklet-gcp.js

This file was deleted.

26 changes: 26 additions & 0 deletions services/dsp/src/public/js/private-aggregation-worklet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class TestPrivateAggregation {
async run(data) {
let cloudEnv = await sharedStorage.get('cloudenv');
console.log(`Enabling ${cloudEnv} Private Aggregation Debug Mode`);
privateAggregation.enableDebugMode({debugKey: 1234n});
let bucketKey = await sharedStorage.get('bucket');
if (bucketKey === 'undefined') {
console.log(
'No bucket key found for client. Adding default bucketKey 1234567890.',
);
bucketKey = '1234567890';
sharedStorage.set('bucketKey', bucketKey);
} else {
console.log(`Bucket Key found: ${bucketKey}`);
}
function convertToBucket(bucketId) {
return BigInt(bucketId);
}
const bucket = convertToBucket(bucketKey);
const value = 128;
privateAggregation.contributeToHistogram({bucket, value});
sharedStorage.clear();
}
}

register('test-private-aggregation', TestPrivateAggregation);
22 changes: 22 additions & 0 deletions services/dsp/src/public/js/private-aggregation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
let bucket = document.currentScript.getAttribute('bucket');
let cloudEnv = document.currentScript.getAttribute('cloudenv');

sharedStorage.set('bucket', `${bucket}`);
sharedStorage.set('cloudenv', `${cloudEnv}`);
console.log(
`https://publickeyservice.msmt.${cloudEnv}.privacysandboxservices.com`,
);

async function runPrivateAggregation() {
const privateAggCloud = {
'privateAggregationConfig': {
'aggregationCoordinatorOrigin': `https://publickeyservice.msmt.${cloudEnv}.privacysandboxservices.com`,
},
};
await window.sharedStorage.worklet.addModule(
'js/private-aggregation-worklet.js',
);
await window.sharedStorage.run('test-private-aggregation', privateAggCloud);
}

runPrivateAggregation();
5 changes: 0 additions & 5 deletions services/dsp/src/views/private-aggregation-aws.ejs

This file was deleted.

5 changes: 0 additions & 5 deletions services/dsp/src/views/private-aggregation-gcp.ejs

This file was deleted.

2 changes: 1 addition & 1 deletion services/dsp/src/views/private-aggregation.ejs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<html>
<header>
<script src="/js/private-aggregation.js"></script>
<script src="/js/private-aggregation.js" bucket="<%= `${bucket}` %>" cloudenv="<%= `${cloudEnv}` %>"></script>
</header>
</html>
4 changes: 4 additions & 0 deletions services/news/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ app.set('views', 'src/views');

app.get('/', async (req: Request, res: Response) => {
const {auctionType} = req.query;
const bucket = req.query.key;
const cloudEnv = req.query.env;

res.render('index', {
title: TITLE,
Expand All @@ -61,6 +63,8 @@ app.get('/', async (req: Request, res: Response) => {
AD_SERVER_LIB_URL: `https://${AD_SERVER_HOST}/js/ad-server-lib.js`,
HEADER_BIDDING_LIB_URL: `https://${NEWS_HOST}/js/header-bidding-lib.js`,
isMultiSeller: auctionType === 'multi',
bucket: bucket,
cloudEnv: cloudEnv,
});
});

Expand Down
2 changes: 1 addition & 1 deletion services/news/src/views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<link rel="stylesheet" href="/css/video-ad-style.css">
<link rel="icon" href="/img/spy.svg" />
<meta http-equiv="origin-trial" content="<%= NEWS_TOKEN %>">
<script src="<%= `https://${DSP_HOST}:${EXTERNAL_PORT}/js/dsp.js` %>" dsp="<%= `${DSP_HOST}:${EXTERNAL_PORT}` %>"></script>
<script src="<%= `https://${DSP_HOST}:${EXTERNAL_PORT}/js/dsp.js` %>" dsp="<%= `${DSP_HOST}:${EXTERNAL_PORT}` %>" bucket="<%= `${bucket}` %>" cloudenv="<%= `${cloudEnv}` %>"></script>
<script defer src="//imasdk.googleapis.com/js/sdkloader/ima3.js"></script>
<script defer src="/js/video-ad-helper.js"></script>
<style>
Expand Down

0 comments on commit 3a96fcf

Please sign in to comment.