Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
gdpr-cookies
Advanced tools
System for website. informs the visitor of the use of cookies and gives the possibility to refuse cookies
ℹ️ On the first visit, the banner is show. If the visitor click a link or a button in page, the cookies are accepted by default.
gdpr-cookies.css 7ko (~2ko gzip)
gdpr-cookies.js 69ko (~19ko gzip)
<script src="path/gdpr-cookies.js" async></script>
<link href="path/gdpr-cookies.css" rel="stylesheet" />
Set this code in the head of your page
<script>var _gdpr = _gdpr || [];</script>
Add your script service (see example google tag bellow )
_gdpr.push([.....]);
And use global function for init GdprCookie (footer)
document.addEventListener('DOMContentLoaded', function () {
window.initGdprCookie.default('fr');
});
install package
npm install gdpr-cookies
import in your javascript file
import initGdprCookie from 'gdpr-cookies';
And use function for init GdprCookie
initGdprCookie('fr');
import sass files
@import 'path-to-your-node_modules/gdpr-cookies/dist/gdpr-cookies.css';
Push array in _gdpr array.
_gdpr.push([
{
name: '',
type: '',
description: ''
},
[callback, callback,..]
])
First element is object:
Second element is Array of Functions
All the callback function called if service is allowed
You can use argument helpers in function.
createScript(src)
for create script tag in headcreateStyle(href)
for create style tag in headcreateIframe('target', {href: '', width: '200px'});
for create iframe tag in target element. Add attribute for
iframe with second argument options object. target is used with document.querySelector<script type="text/javascript">
_gdpr.push([
{
type: 'stats',
name: 'Google Tag',
description: 'Service pour statistiques des visites'
},
[
function(helpers) {
// use helpers
helpers.createScript('https://www.googletagmanager.com/gtag/js?id=' + keys_api.gtag);
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments)
}
gtag('js', new Date());
gtag('config', '########');
}
]
]);
</script>
var myCB = [];
// declare service
_gdpr.push([
{
type: 'stats',
name: 'Google Tag',
description: 'Service pour statistiques des visites'
},
myCB
]);
// ...
// on the page
<script type="text/javascript">
myCB.push(function(helpers){ return true;});
</script>
You can define lang with (default is fr):
var _gdpr_lang = 'fr';
var _gdpr_options = {
name: 'gdpr_cookie', // name of cookie gdpr
keepCookies: ['TEST'], // cookie not to delete
types: ['ads', 'stats', 'others'], // type of services
expires: 395, // cookie duration (in days)
optout: true, // default undefined. If true, the services is optout.
};
The message by default exists for fr, en and es. If you want to add or define your messages, you can create a messages in your html, ex :
var _gdpr_messages = {
fr: {
banner_title: "Information sur l'utilisation de cookies sur le site",
alert_text:
"En poursuivant votre navigation, vous acceptez l'utilisation de services tiers pouvant installer des cookies",
banner_ok_bt: 'Ok, tout accepter',
banner_custom_bt: 'Personnaliser les cookies',
modal_header_txt: 'Préférence pour tous les services',
close_modale_label: 'Fermer la fenêtre',
service_accept: 'Activer',
service_accept_all: 'Activer tous les services',
service_bloc_all: 'Bloquer tous les services',
service_activated: 'Service activé',
service_blocked: 'Service bloqué',
modal_valid: 'Appliquer les reglages',
ads: 'Publicités',
stats: 'Statistiques',
others: 'Autres services',
mask_text_start: 'Le service',
mask_text_end: 'est désactivé',
activate: 'activer',
deactivate: 'désactiver',
},
};
window._gdpr_showModal();
ex:
<a href="#" onclick="window._gdpr_showModal();return false;">Show modal</a>
Add just class (gdpr-mask) and name of service with data-gdpr. Ex:
<div
id="map"
class="gdpr-mask"
data-gdpr="Google Map"
style="width: 100%; height: 400px;"
></div>
The code use :
For UI :
Desktop:
Mobile
FAQs
System for website. informs the visitor of the use of cookies and gives the possibility to refuse cookies
The npm package gdpr-cookies receives a total of 0 weekly downloads. As such, gdpr-cookies popularity was classified as not popular.
We found that gdpr-cookies demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.