Socket
Socket
Sign inDemoInstall

@dmstr/cookie-consent

Package Overview
Dependencies
0
Maintainers
3
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.0 to 0.4.1

.github/workflows/main.yml

2

dist/cookie-consent.js

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.CookieConsent=e():t.CookieConsent=e()}(window,(function(){return function(t){var e={};function o(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,o),s.l=!0,s.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)o.d(n,s,function(e){return t[e]}.bind(null,s));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=0)}([function(t,e,o){"use strict";o.r(e);var n=function(t){this.defaultsOptions={name:"cookie_consent_status",value:[],path:"/",domain:"",expiryDays:365},this.options=this.mergeObjects(this.defaultsOptions,t),this.inputs=[].slice.call(document.querySelectorAll("[data-cc-consent]")),this.popup=document.querySelector(".cookie-consent-popup"),this.controls=document.querySelector(".cookie-consent-controls"),this.details=document.querySelector(".cookie-consent-details"),this.saveButtons=[].slice.call(document.querySelectorAll(".cookie-consent-save")),this.acceptAllButtons=[].slice.call(document.querySelectorAll(".cookie-consent-accept-all")),this.denyAllButtons=[].slice.call(document.querySelectorAll(".cookie-consent-deny-all")),this.openControlsButtons=[].slice.call(document.querySelectorAll(".cookie-consent-controls-open")),this.closeControlsButtons=[].slice.call(document.querySelectorAll(".cookie-consent-controls-close")),this.toggleControlsButtons=[].slice.call(document.querySelectorAll(".cookie-consent-controls-toggle")),this.openDetailsButtons=[].slice.call(document.querySelectorAll(".cookie-consent-details-open")),this.closeDetailsButtons=[].slice.call(document.querySelectorAll(".cookie-consent-details-close")),this.toggleDetailsButtons=[].slice.call(document.querySelectorAll(".cookie-consent-details-toggle")),this.openButtons=[].slice.call(document.querySelectorAll(".cookie-consent-open")),this.closeButtons=[].slice.call(document.querySelectorAll(".cookie-consent-close")),this.toggleButtons=[].slice.call(document.querySelectorAll(".cookie-consent-toggle")),this.addEventListeners(),void 0===this.get()&&this.open(),this.refreshUI()};n.prototype.open=function(){this.popup&&this.popup.classList.add("open")},n.prototype.close=function(){this.popup&&this.popup.classList.remove("open")},n.prototype.openControls=function(){this.controls&&this.controls.classList.add("open")},n.prototype.closeControls=function(){this.controls&&this.controls.classList.remove("open")},n.prototype.openDetails=function(){this.details&&this.details.classList.add("open")},n.prototype.closeDetails=function(){this.details&&this.details.classList.remove("open")},n.prototype.addEventListeners=function(){var t=this;this.toggleButtons.length>0&&this.toggleButtons.forEach((function(e){e.addEventListener("click",(function(){t.popup.classList.contains("open")?t.close():t.open()}))})),this.openDetailsButtons.length>0&&this.openDetailsButtons.forEach((function(e){e.addEventListener("click",(function(){t.open(),t.openDetails()}))})),this.closeDetailsButtons.length>0&&this.closeDetailsButtons.forEach((function(e){e.addEventListener("click",(function(){t.closeDetails()}))})),this.toggleDetailsButtons.length>0&&this.toggleDetailsButtons.forEach((function(e){e.addEventListener("click",(function(){t.details.classList.contains("open")?t.closeDetails():(t.open(),t.openDetails())}))})),this.openControlsButtons.length>0&&this.openControlsButtons.forEach((function(e){e.addEventListener("click",(function(){t.open(),t.openControls()}))})),this.closeControlsButtons.length>0&&this.closeControlsButtons.forEach((function(e){e.addEventListener("click",(function(){t.closeControls()}))})),this.toggleControlsButtons.length>0&&this.toggleControlsButtons.forEach((function(e){e.addEventListener("click",(function(){t.controls.classList.contains("open")?t.closeControls():(t.open(),t.openControls())}))})),this.saveButtons.length>0&&this.saveButtons.forEach((function(e){e.addEventListener("click",(function(){t.save()}))})),this.acceptAllButtons.length>0&&this.acceptAllButtons.forEach((function(e){e.addEventListener("click",(function(){t.inputs.length>0&&t.inputs.forEach((function(t){t.checked=!0})),t.save()}))})),this.denyAllButtons.length>0&&this.denyAllButtons.forEach((function(e){e.addEventListener("click",(function(){t.inputs.length>0&&t.inputs.forEach((function(t){t.checked=!1})),t.save()}))})),this.openButtons.length>0&&this.openButtons.forEach((function(e){e.addEventListener("click",(function(){t.open()}))})),this.closeButtons.length>0&&this.closeButtons.forEach((function(e){e.addEventListener("click",(function(){t.close()}))}))},n.prototype.save=function(){var t=this;this.set(this.options),this.inputs.length>0&&this.inputs.forEach((function(e){var o=e.getAttribute("data-cc-consent");e.checked?t.add(o):t.remove(o)})),this.refreshUI(),this.afterSave(this)},n.prototype.refreshUI=function(){var t=this;void 0!==this.get()&&this.inputs.forEach((function(e){var o=e.getAttribute("data-cc-consent");e.checked=t.has(o)}))},n.prototype.set=function(t){var e=new Date;e.setDate(e.getDate()+(t.expiryDays||365));var o=[t.name+"="+JSON.stringify(t.value),"expires="+e.toUTCString(),"path="+(t.path||"/")];t.domain&&o.push("domain="+t.domain),document.cookie=o.join(";")},n.prototype.get=function(){var t=("; "+document.cookie).split("; "+this.options.name+"="),e=2!==t.length?void 0:t.pop().split(";").shift();return void 0!==e?JSON.parse(e):e},n.prototype.has=function(t){var e=this.get();return void 0!==e&&e.indexOf(t)>-1},n.prototype.add=function(t){var e=this.get();if(void 0!==e&&!e.indexOf(t)>-1){e.push(t);var o=this.mergeObjects(this.defaultsOptions,{value:e});return this.set(o),!0}return!1},n.prototype.remove=function(t){var e=this.get();if(void 0===e)return!1;var o=e.indexOf(t);if(o>-1){e.splice(o,1);var n=this.mergeObjects(this.defaultsOptions,{value:e});return this.set(n),!0}return!1},n.prototype.clean=function(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&!this.has(e)){var o=t[e].cookies;for(var n in o)if(Object.prototype.hasOwnProperty.call(o,n)){var s={name:o[n].name,expiryDays:-1};void 0!==o[n].domain&&(s.domain=o[n].domain),void 0!==o[n].path&&(s.path=o[n].path),this.set(s)}}},n.prototype.mergeObjects=function(){for(var t={},e=0;e<arguments.length;e++)for(var o in arguments[e])Object.prototype.hasOwnProperty.call(arguments[e],o)&&(t[o]=arguments[e][o]);return t},n.prototype.afterSave=function(){},e.default=n}]).default}));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.CookieConsent=e():t.CookieConsent=e()}(self,(()=>(()=>{"use strict";var t={d:(e,o)=>{for(var n in o)t.o(o,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:o[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{default:()=>n});var o=function(t){this.defaultsOptions={name:"cookie_consent_status",value:[],path:"/",domain:"",expiryDays:365},this.options=this.mergeObjects(this.defaultsOptions,t),this.inputs=[].slice.call(document.querySelectorAll("[data-cc-consent]")),this.popup=document.querySelector(".cookie-consent-popup"),this.controls=document.querySelector(".cookie-consent-controls"),this.details=document.querySelector(".cookie-consent-details"),this.saveButtons=[].slice.call(document.querySelectorAll(".cookie-consent-save")),this.acceptAllButtons=[].slice.call(document.querySelectorAll(".cookie-consent-accept-all")),this.denyAllButtons=[].slice.call(document.querySelectorAll(".cookie-consent-deny-all")),this.openControlsButtons=[].slice.call(document.querySelectorAll(".cookie-consent-controls-open")),this.closeControlsButtons=[].slice.call(document.querySelectorAll(".cookie-consent-controls-close")),this.toggleControlsButtons=[].slice.call(document.querySelectorAll(".cookie-consent-controls-toggle")),this.openDetailsButtons=[].slice.call(document.querySelectorAll(".cookie-consent-details-open")),this.closeDetailsButtons=[].slice.call(document.querySelectorAll(".cookie-consent-details-close")),this.toggleDetailsButtons=[].slice.call(document.querySelectorAll(".cookie-consent-details-toggle")),this.openButtons=[].slice.call(document.querySelectorAll(".cookie-consent-open")),this.closeButtons=[].slice.call(document.querySelectorAll(".cookie-consent-close")),this.toggleButtons=[].slice.call(document.querySelectorAll(".cookie-consent-toggle")),this.addEventListeners(),void 0===this.get()&&this.open(),this.refreshUI()};o.prototype.open=function(){this.popup&&this.popup.classList.add("open")},o.prototype.close=function(){this.popup&&this.popup.classList.remove("open")},o.prototype.openControls=function(){this.controls&&this.controls.classList.add("open")},o.prototype.closeControls=function(){this.controls&&this.controls.classList.remove("open")},o.prototype.openDetails=function(){this.details&&this.details.classList.add("open")},o.prototype.closeDetails=function(){this.details&&this.details.classList.remove("open")},o.prototype.addEventListeners=function(){var t=this;this.toggleButtons.length>0&&this.toggleButtons.forEach((function(e){e.addEventListener("click",(function(){t.popup.classList.contains("open")?t.close():t.open()}))})),this.openDetailsButtons.length>0&&this.openDetailsButtons.forEach((function(e){e.addEventListener("click",(function(){t.open(),t.openDetails()}))})),this.closeDetailsButtons.length>0&&this.closeDetailsButtons.forEach((function(e){e.addEventListener("click",(function(){t.closeDetails()}))})),this.toggleDetailsButtons.length>0&&this.toggleDetailsButtons.forEach((function(e){e.addEventListener("click",(function(){t.details.classList.contains("open")?t.closeDetails():(t.open(),t.openDetails())}))})),this.openControlsButtons.length>0&&this.openControlsButtons.forEach((function(e){e.addEventListener("click",(function(){t.open(),t.openControls()}))})),this.closeControlsButtons.length>0&&this.closeControlsButtons.forEach((function(e){e.addEventListener("click",(function(){t.closeControls()}))})),this.toggleControlsButtons.length>0&&this.toggleControlsButtons.forEach((function(e){e.addEventListener("click",(function(){t.controls.classList.contains("open")?t.closeControls():(t.open(),t.openControls())}))})),this.saveButtons.length>0&&this.saveButtons.forEach((function(e){e.addEventListener("click",(function(){t.save()}))})),this.acceptAllButtons.length>0&&this.acceptAllButtons.forEach((function(e){e.addEventListener("click",(function(){t.inputs.length>0&&t.inputs.forEach((function(t){t.checked=!0})),t.save()}))})),this.denyAllButtons.length>0&&this.denyAllButtons.forEach((function(e){e.addEventListener("click",(function(){t.inputs.length>0&&t.inputs.forEach((function(t){t.checked=!1})),t.save()}))})),this.openButtons.length>0&&this.openButtons.forEach((function(e){e.addEventListener("click",(function(){t.open()}))})),this.closeButtons.length>0&&this.closeButtons.forEach((function(e){e.addEventListener("click",(function(){t.close()}))}))},o.prototype.save=function(){var t=this;this.set(this.options),this.inputs.length>0&&this.inputs.forEach((function(e){var o=e.getAttribute("data-cc-consent");e.checked?t.add(o):t.remove(o)})),this.refreshUI(),this.afterSave(this)},o.prototype.refreshUI=function(){var t=this;void 0!==this.get()&&this.inputs.forEach((function(e){var o=e.getAttribute("data-cc-consent");e.checked=t.has(o)}))},o.prototype.set=function(t){var e=new Date;e.setDate(e.getDate()+(t.expiryDays||365));var o=[t.name+"="+JSON.stringify(t.value),"expires="+e.toUTCString(),"path="+(t.path||"/")];t.domain&&o.push("domain="+t.domain),document.cookie=o.join(";")},o.prototype.get=function(){var t=("; "+document.cookie).split("; "+this.options.name+"="),e=2!==t.length?void 0:t.pop().split(";").shift();return void 0!==e?JSON.parse(e):e},o.prototype.has=function(t){var e=this.get();return void 0!==e&&e.indexOf(t)>-1},o.prototype.add=function(t){var e=this.get();if(void 0!==e&&!e.indexOf(t)>-1){e.push(t);var o=this.mergeObjects(this.options,{value:e});return this.set(o),!0}return!1},o.prototype.remove=function(t){var e=this.get();if(void 0===e)return!1;var o=e.indexOf(t);if(o>-1){e.splice(o,1);var n=this.mergeObjects(this.options,{value:e});return this.set(n),!0}return!1},o.prototype.clean=function(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&!this.has(e)){var o=t[e].cookies;for(var n in o)if(Object.prototype.hasOwnProperty.call(o,n)){var s={name:o[n].name,expiryDays:-1};void 0!==o[n].domain&&(s.domain=o[n].domain),void 0!==o[n].path&&(s.path=o[n].path),this.set(s)}}},o.prototype.mergeObjects=function(){for(var t={},e=0;e<arguments.length;e++)for(var o in arguments[e])Object.prototype.hasOwnProperty.call(arguments[e],o)&&(t[o]=arguments[e][o]);return t},o.prototype.afterSave=function(){};const n=o;return e.default})()));
{
"name": "@dmstr/cookie-consent",
"version": "0.4.0",
"version": "0.4.1",
"description": "Library to address GDPR (The General Data Protection Regulation)",

@@ -35,4 +35,4 @@ "main": "dist/cookie-consent.js",

"live-server": "^1.2.1",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.5"
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4"
},

@@ -39,0 +39,0 @@ "bugs": {

@@ -243,3 +243,3 @@ const CookieConsent = function (options) {

value.push(consent)
const options = this.mergeObjects(this.defaultsOptions, { value: value })
const options = this.mergeObjects(this.options, { value: value })
this.set(options)

@@ -260,3 +260,3 @@ return true

value.splice(index, 1)
const options = this.mergeObjects(this.defaultsOptions, { value: value })
const options = this.mergeObjects(this.options, { value: value })
this.set(options)

@@ -263,0 +263,0 @@ return true

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc