diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index aaa5e35e..1fb9302a 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -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 diff --git a/services/dsp/src/index.ts b/services/dsp/src/index.ts index 35761e5b..70a0cafd 100644 --- a/services/dsp/src/index.ts +++ b/services/dsp/src/index.ts @@ -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( diff --git a/services/dsp/src/public/js/dsp.js b/services/dsp/src/public/js/dsp.js index 2fcaede0..122cf60a 100644 --- a/services/dsp/src/public/js/dsp.js +++ b/services/dsp/src/public/js/dsp.js @@ -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); + } }); diff --git a/services/dsp/src/public/js/private-aggregation-aws.js b/services/dsp/src/public/js/private-aggregation-aws.js deleted file mode 100644 index eb3d14b1..00000000 --- a/services/dsp/src/public/js/private-aggregation-aws.js +++ /dev/null @@ -1,14 +0,0 @@ -async function runPrivateAggregationAws() { - const privateAggCloud = { - 'privateAggregationConfig': { - 'aggregationCoordinatorOrigin': - 'https://publickeyservice.msmt.aws.privacysandboxservices.com', - }, - }; - await window.sharedStorage.worklet.addModule( - 'js/private-aggregation-worklet-aws.js', - ); - await window.sharedStorage.run('test-private-aggregation', privateAggCloud); -} - -runPrivateAggregationAws(); diff --git a/services/dsp/src/public/js/private-aggregation-gcp.js b/services/dsp/src/public/js/private-aggregation-gcp.js deleted file mode 100644 index cefbb8be..00000000 --- a/services/dsp/src/public/js/private-aggregation-gcp.js +++ /dev/null @@ -1,14 +0,0 @@ -async function runPrivateAggregationGcp() { - const privateAggCloud = { - 'privateAggregationConfig': { - 'aggregationCoordinatorOrigin': - 'https://publickeyservice.msmt.gcp.privacysandboxservices.com', - }, - }; - await window.sharedStorage.worklet.addModule( - 'js/private-aggregation-worklet-gcp.js', - ); - await window.sharedStorage.run('test-private-aggregation', privateAggCloud); -} - -runPrivateAggregationGcp(); diff --git a/services/dsp/src/public/js/private-aggregation-worklet-aws.js b/services/dsp/src/public/js/private-aggregation-worklet-aws.js deleted file mode 100644 index 6c72ddde..00000000 --- a/services/dsp/src/public/js/private-aggregation-worklet-aws.js +++ /dev/null @@ -1,24 +0,0 @@ -class TestPrivateAggregation { - async run(data) { - console.log('Enabling AWS 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); diff --git a/services/dsp/src/public/js/private-aggregation-worklet-gcp.js b/services/dsp/src/public/js/private-aggregation-worklet-gcp.js deleted file mode 100644 index 586ebd80..00000000 --- a/services/dsp/src/public/js/private-aggregation-worklet-gcp.js +++ /dev/null @@ -1,24 +0,0 @@ -class TestPrivateAggregation { - async run(data) { - console.log('Enabling GCP 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); diff --git a/services/dsp/src/public/js/private-aggregation-worklet.js b/services/dsp/src/public/js/private-aggregation-worklet.js new file mode 100644 index 00000000..f1cb7f78 --- /dev/null +++ b/services/dsp/src/public/js/private-aggregation-worklet.js @@ -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); diff --git a/services/dsp/src/public/js/private-aggregation.js b/services/dsp/src/public/js/private-aggregation.js new file mode 100644 index 00000000..0ec8dc87 --- /dev/null +++ b/services/dsp/src/public/js/private-aggregation.js @@ -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(); diff --git a/services/dsp/src/views/private-aggregation-aws.ejs b/services/dsp/src/views/private-aggregation-aws.ejs deleted file mode 100644 index 6e29dc87..00000000 --- a/services/dsp/src/views/private-aggregation-aws.ejs +++ /dev/null @@ -1,5 +0,0 @@ - -
- -
- \ No newline at end of file diff --git a/services/dsp/src/views/private-aggregation-gcp.ejs b/services/dsp/src/views/private-aggregation-gcp.ejs deleted file mode 100644 index d3c8f54b..00000000 --- a/services/dsp/src/views/private-aggregation-gcp.ejs +++ /dev/null @@ -1,5 +0,0 @@ - -
- -
- \ No newline at end of file diff --git a/services/dsp/src/views/private-aggregation.ejs b/services/dsp/src/views/private-aggregation.ejs index 81aeb6b5..1f2508e8 100644 --- a/services/dsp/src/views/private-aggregation.ejs +++ b/services/dsp/src/views/private-aggregation.ejs @@ -1,5 +1,5 @@
- +
\ No newline at end of file diff --git a/services/news/src/index.ts b/services/news/src/index.ts index 2db209e8..71573f99 100644 --- a/services/news/src/index.ts +++ b/services/news/src/index.ts @@ -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, @@ -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, }); }); diff --git a/services/news/src/views/index.ejs b/services/news/src/views/index.ejs index 1499a141..93d9340c 100644 --- a/services/news/src/views/index.ejs +++ b/services/news/src/views/index.ejs @@ -9,7 +9,7 @@ - +