0.1.1 • Published 3 years ago

privacysandbox.js v0.1.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

privacysandbox.js

This JS library contains my experiments around Google Chrome's Privacy Sandbox.

I have not yet decided which way this is going. Currently, it tries to bring some Privacy Sandbox APIs to unsupported browsers, such as Firefox, Safari or... Chrome :)

Usage

Browser

<script src='privacysandbox.min.js'></script>

Server

npm install
#for starting Express server:
node server.js

#or, for development:
npm run serve

Privacy Sandbox

Federated Learning of Cohorts

This implementation stores user browsing history in localStorage (only within one domain) and generates cohort_id using simhash algorithm.

After including privacysandbox.min.js file on website, you can get cohort id of the user:

(async () => {
    cohort = await PrivacySandbox.floc.interestCohort();
    url = new URL("https://ads.example/getCreative");
    url.searchParams.append("cohort", cohort);
    creative = await fetch(url);
})();

You can replace (or initialize) FLoC API:

PrivacySandbox.floc.force();

You can also disable FLoC:

PrivacySandbox.floc.disable();

// or pass fixed cohort id:
PrivacySandbox.floc.disable('437737');
0.1.1

3 years ago

0.1.0

3 years ago