Tools for bringing Microsoft websites into compliance with the EU cookie policies.
Create an instance of the module:
var MSCC = require('microsoft-cookie-compliance');
var mscc = new MSCC({
domain: 'partners.office.com', // Domain of the site
siteName: 'Office 365 Partner Portal', // This should be same as name the site is registered with on the cookie portal
geoIPKey: 'secretKey', // secret key for the GEOIP database service
overrideGeoIP: 'US', // (optional) allow GEOIP database to be skipped and hardcoded to a specific value - useful to avoid downloading the database a lot during development
consentUri: 'https://uhf.microsoft.com/en-us/shell/api/mscc' // (optional) the locale specified is used to generate a banner with the correct language
});
For each request the express middleware will ensure the cookie compliance information is attached to res.locals.mscc
to support the handlebars helpers
app.use(require('microsoft-cookie-compliance/express')(mscc));
For each request the koa middleware will ensure the cookie compliance information is attached to ctx.state.mscc
to support the handlebars helpers
app.use(require('microsoft-cookie-compliance/koa')(mscc));
Includes 3 helpers for displaying the cookie compliance banner and conditionally including code based on compliance status. To use, first register the handlebars helpers:
var msccRegisterHandlebars = require('microsoft-cookie-compliance/handlebars');
msccRegisterHandlebars(Handlebars);
If consent has been obtained, or is not required, this block helper simply passes the content through to the HTML. If consent hasn't been obtained yet, it wraps the content in a javascript function that adds it to the page once consent is obtained.
Inserts the Javascript and CSS references that are required to display the notification banner, and to obtain consent. This should be used once, in the header
Inserts the HTML for the consent banner
There are two ways to run the unit tests, normally:
npm test
and in debug mode (using electron for debugging):
npm run debug-test