Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@lucidclient/cookie-controller
Advanced tools
A lightweight, bring your own markup and styles, cookie consent solution to help you comply with the EU Cookie Law and GDPR.
Part of the Lucid Client suite
A lightweight, bring your own markup and styles, cookie consent solution. Perfect for agencies, enterprise teams and individuals who need full control over their cookie consent implementation and UX.
To install the Cookie Controller library, run the following command:
npm install @lucidclient/cookie-controller
All config for the init function is optional.
import cookieController from "@lucidclient/cookie-controller";
cookieController.init({
onConsentChange: (data) => {
console.log(data);
},
essentialCookies: true,
categoryCookies: {
analytics: ["_ga", "_gid"],
marketing: ["mkto"],
},
});
The following Options
type is used for the init functions options parameter.
type ConsentChange = {
/**
* The consent change type
* - change: when a cookie checkbox is changed
* - accept: when the accept button is clicked
* - reject: when the reject button is clicked
* - save: when the save button is clicked
* - onload: when the library is initialised
*/
type: "change" | "accept" | "reject" | "save" | "onload";
/**
* The users UUID
*/
uuid: string;
/**
* The version of the cookie policy
*/
version?: string;
/**
* The cookie category that has changed
* - this is only present when the type is "change", triggered by a cookie checkbox change
*/
changed?: {
category: string;
consented: boolean;
cookies: Array<string>;
};
/**
* All of the cookie category states
*/
categories: Array<{
category: string;
consented: boolean;
cookies: Array<string>;
}>;
};
type StorageOptions = {
path?: string;
domain?: string;
sameSite?: "Strict" | "Lax" | "None";
secure?: boolean;
expires?: number | Date;
};
type Options = {
/**
* Set to true if you have essential cookies. This will return an extra category item called "essential" in the categories array on the onConsentChange callback
*/
essentialCookies?: boolean;
/**
* A list of cookies that get added when a certain cateogry is consented
* - Ie: analytics: ["_ga", "_gid"]
*
* Note that these are just returned in the onConsentChange callback, they are not added/removed from the users cookies
*/
categoryCookies?: Record<string | "esential", Array<string>>;
/**
* A callback that is fired whenever the consent state changes
*/
onConsentChange?: ((data: ConsentChange) => void);
/**
* A callback that is fired whenever a user state has a different version of the cookie policy to the current version
*/
version?: {
/**
* The current version of the cookie policy
*/
current: string;
/**
* The callback
*/
onNewVersion?: (oldVersion: string, newVersion: string) => void;
};
/**
* Configure the options for the cookie used to store the user's preferences
*/
storage?: StorageOptions;
};
An any page there should only ever be one data-cookie-details
element, and one data-cookie-alert
element. With the data-cookie-action
attributes, you can add as many as you like.
<div data-cookie-details>
<button data-cookie-action="dismiss">Close</button>
<button data-cookie-action="accept">Accept Recommended</button>
<button data-cookie-action="reject">Reject</button>
<a href="https://www.example.com/privacy-policy" target="_blank">
Cookie Policy
</a>
<ul>
<li>
<p>Essential Cookies:</p>
<p>...</p>
</li>
<li>
<input id="analytics" type="checkbox" data-cookie-category="analytics" />
<label for="analytics">Analytics:</label>
<p>...</p>
</li>
<li>
<input id="marketing" type="checkbox" data-cookie-category="marketing" />
<label for="marketing">Marketing:</label>
<p>...</p>
</li>
</ul>
<button data-cookie-action="save">Save My Preferences</button>
</div>
<div data-cookie-alert>
<button data-cookie-action="accept">Accept All</button>
<button data-cookie-action="reject">Reject</button>
<button data-cookie-action="details">Details</button>
<button data-cookie-action="dismiss">Close</button>
</div>
<button data-cookie-action="details">Open Cookie Modal</button>
For a more detailed example, checkout the tailwind.html example.
Our cookie controller is developed with GDPR considerations in mind. While this tool offers functionalities aligning with GDPR requirements, full compliance depends on how it is implemented within your website's broader context and architecture.
Here are some tips for achieving compliance:
data-cookie-config
attribute, as they are for informational purposes only. In this case you may want to use the essentialCookies
config option.Please note this is not an exhaustive list, and we recommend seeking legal advice to ensure full compliance.
FAQs
A lightweight, bring your own markup and styles, cookie consent solution to help you comply with the EU Cookie Law and GDPR.
We found that @lucidclient/cookie-controller demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.