pwix:cookie-manager
A cookie management package for Meteor which aims to conform to "Guidelines 05/2020 on consent under Regulation 2016/679" EU recomandations.
It provides:
-
the methods to let the application (resp. another package) publish their respectives cookies to respect the disclosure obligation
-
a consentement dialog as a Blaze component
-
the methods to let the application (resp. another package) get the cookies status.
This has been written because selaias:cookie-consent seems to no more be maintained. So the need of a current package has arisen. Note that, contrarily to selaias:cookie-consent, this one doesn't requise ostrio:cookies. Instead, it relies on localStorage to store user consentement.
The cookie object
pwix:cookie-manager doesn't manage the cookies by themselves, I mean their value. So, whether the cookie is really a cookie, i.e. a data file sent from the server to the client before HTTP headers, and so on, is entirey up to the application (resp. another package).
Instead, pwix:cookie-manager manages what can be called the cookie semantic, i.e. a name and a description, an originator, a category, a status, along with some other properties which are only lelevant for the aim of management. All that semantic, along wihh the user consentement, is stored in the localStorage of the browser.
pwix:cookie-manager distinguishes five type of cookies:
CM_CAT_TECHNICALSCM_CAT_FUNCTIONALSCM_CAT_STATISTICSCM_CAT_MARKETINGCM_CAT_THIRD
pwix:cookie-manager makes the cookie have three status:
-
it may be enabled and not disableable: the cookie is operational, and the user cannot refuse it
-
it may be enabled and disableable: the cookie defaults to be operational, but the user can refuse it
-
it may be disabled: the cookie is not operational, has been previously refused by the user.
Configuration
The package's behavior can be configured through a call to the cookieManager.configure() method, with just a single javascript object argument, which itself should only contains the options you want override.
There is at the moment a single configuration option:
-
verbosityDefine the expected verbosity level.
The accepted value can be any or-ed combination of following:
-
CM_VERBOSE_NONEDo not display any trace log to the console
-
CM_VERBOSE_COMPONENTSTrace Blaze components life:
- creation
- rendering
- destruction
-
CM_VERBOSE_CONFIGURETrace
cookieManager.configure()calls and their result -
CM_VERBOSE_DUMPDump the
cookieManagerglobal object at startup. -
CM_VERBOSE_STORAGEDump the localStorage first at startup, and then on user choice from
cmConsent(client-side only).
-
Please note that cookieManager.configure() method should be called in the same terms both in client and server sides.
Also note, as an explicit reminder for the fools, that, because the Meteor packages are instanciated at application level, they can be configured once at most, and only once at most. Each addtionnal call to cookieManager.configure() will just override the previous one. You have been warned: only the application should configure a package.
Provides
A global object
cookieManager
This object is allocated at package level: there is only one instance in your application. It gathers the available methods (see below).
pwix:cookie-manager attaches this global object to the global Meteor one, so that every willing-to packages is able to take advantage of the available methods to publish their own cookies throught Meteor.cookieManager, without having to first require or import the package, or even make it a dependency.
Constants
-
CM_VERBOSE_NONE -
CM_VERBOSE_COMPONENTS -
CM_VERBOSE_CONFIGURE -
CM_VERBOSE_DUMP -
CM_VERBOSE_STORAGE -
CM_CAT_TECHNICALS -
CM_CAT_FUNCTIONALS -
CM_CAT_STATISTICS -
CM_CAT_MARKETING -
CM_CAT_THIRD
References
cookieManager.Categories
The array of the known cookies categories:
CM_CAT_TECHNICALSCM_CAT_FUNCTIONALSCM_CAT_STATISTICSCM_CAT_MARKETINGCM_CAT_THIRD
Methods
cookieManager.byCategory( category )
Returns the array of published cookies for the specified category.
cookieManager.configure( o )
See above.
cookieManager.isEnabled( name )
Returns whether the named cookie is authorized by the user.
cookieManager.publish( o )
This method let the application (resp. another package) publish the cookies it makes use of, so that the user is able to be informed of what he accepts or refuses.
In order to not rely on the initialization order, this method should be called from Meteor.startup().
o here is either a javascript object which describes a cookie, or an array of such javascript objects. It may contains following datas:
-
nameThe technical name of the cookie, as a string, so that, for example, this coud be checked by the user in his browser.
This
nameis expected to be a unique identifier of the cookie, cannot be empty. -
responsibleThe application (resp. another package) name, as a string.
-
categoryThe category the cookie belong to.
Must be referenced in
cookieManager.Categories. -
descriptionA brief description of the role of the cookie, as a string.
Defaulting to none.
-
lifetimeThe lifetime of the cookie, as a string, from just the navigation session life to illimited.
Defaulting to english « Unknown ».
-
disableableWhether the cookie can be refused by the user.
Defaulting to
true. -
linkWhen we are describing a third-party cookie, the third-party main web site address.
Defaulting to none.
Blaze components
cmConsent
A modal dialog which let the user choose his privacy preferences.
The component is configurable with an object passed as an argument, which may contain:
-
dialogTitleAn optional string to be used as title in the dialog header, defaulting to english « Cookies preferences ».
-
acceptButtonAn optional string to be used as the label of the
Accept allbutton, defaulting to english « Accept all ». -
chooseButtonAn optional string to be used as the label of the
Set my choicesbutton, defaulting to english « Set my choices ». -
functionalsAfterAn optional HTML string to be used after the content of the
functionalstab, defaulting to nothing. -
functionalsBeforeAn optional HTML string to be used before the content of the
functionalstab, defaulting to nothing. -
functionalsContentAn optional HTML string to be used as the content of the
functionalstab, defaulting to english« ...
-
functionalsLabelAn optional string to be used as the label of the
functionalsbutton, defaulting to english « Functional cookies ». -
functionalsTitleAn optional HTML string to be used as the title of the
functionalstab, defaulting to HTML '<h5>Functional cookies</h5>'.. -
marketingAfterAn optional HTML string to be used after the content of the
marketingtab, defaulting to nothing. -
marketingBeforeAn optional HTML string to be used before the content of the
marketingtab, defaulting to nothing. -
marketingContentAn optional HTML string to be used as the content of the
marketingtab, defaulting to english« ...
-
marketingLabelAn optional string to be used as the label of the
marketingbutton, defaulting to english « Marketing cookies ». -
marketingTitleAn optional HTML string to be used as the title of the
marketingtab, defaulting to HTML '<h5>Marketing cookies</h5>'.. -
privacyAfterAn optional HTML string to be used after the content of the
privacytab, defaulting to nothing. -
privacyBeforeAn optional HTML string to be used before the content of the
privacytab, defaulting to nothing. -
privacyContentAn optional HTML string to be used as the content of the
privacytab, defaulting to english« When you visit a web site, it may record some informations about you, your device, the previous web site you come from, or any other information it may find useful. « These informations are stored as _cookies, or other comparable technologies, which are essentially small data files. « Because your privacy is essential for us, we request your explicit consent to use and store these cookies.
-
privacyLabelAn optional string to be used as the label of the
privacybutton, defaulting to english « Your privacy ». -
privacyTitleAn optional HTML string to be used as the title of the
privacytab, defaulting to HTML '<h5>Your privacy</h5>'. -
rejectButtonAn optional string to be used as the label of the
Reject allbutton, defaulting to english « Reject all ». -
statisticsAfterAn optional HTML string to be used after the content of the
statisticstab, defaulting to nothing. -
statisticsBeforeAn optional HTML string to be used before the content of the
statisticstab, defaulting to nothing. -
statisticsContentAn optional HTML string to be used as the content of the
statisticstab, defaulting to english« ...
-
statisticsLabelAn optional string to be used as the label of the
statisticsbutton, defaulting to english « Statistics cookies ». -
statisticsTitleAn optional HTML string to be used as the title of the
statisticstab, defaulting to HTML '<h5>Statistics cookies</h5>'.. -
technicalsAfterAn optional HTML string to be used after the content of the
technicalstab, defaulting to nothing. -
technicalsBeforeAn optional HTML string to be used before the content of the
technicalstab, defaulting to nothing. -
technicalsContentAn optional HTML string to be used as the content of the
technicalstab, defaulting to english« ...
-
technicalsLabelAn optional string to be used as the label of the
technicalsbutton, defaulting to english « Technicals cookies ». -
technicalsTitleAn optional HTML string to be used as the title of the
technicalstab, defaulting to HTML '<h5>Technicals cookies</h5>'.. -
thirdAfterAn optional HTML string to be used after the content of the
thirdtab, defaulting to nothing. -
thirdBeforeAn optional HTML string to be used before the content of the
thirdtab, defaulting to nothing. -
thirdContentAn optional HTML string to be used as the content of the
thirdtab, defaulting to english« ...
-
thirdLabelAn optional string to be used as the label of the
thirdbutton, defaulting to english « Third-party cookies ». -
thirdTitleAn optional HTML string to be used as the title of the
thirdtab, defaulting to HTML '<h5>Third-party cookies</h5>'..
This dialog is modal, i.e. it blocks any user input other than clicking one the three buttons.
-
English version

-
French version

cmSliding
A sliding alert band displayed in the bottom of the screen, to let the user be informed or the existence of a cookies policy.
Contrarily to cmConsent, this component is not blocking. The user is able to just ignore it.
As this component provides a link to the cookies manager modal dialog, it may take the exact same parameters than cmConsent, plus some specifics:
-
cookiesPolicyWhether to display a link to the site wookies policy.
If provided, then the component will display a short sentence « Read our cookies policy ».
On click, the
cm-policy-clickevent will be triggered oncmSlidingcomponent.Defaults to
false.
And that is an english version

And a french version

Informational messages
cm-policy-click
This event is triggered on the cmSliding component when the developer has requested the display of a link to the cookies policy, and the user has clicked this link.
NPM peer dependencies
Starting with v 0.1.0, and in accordance with advices from the Meteor Guide, we no more hardcode NPM dependencies in the Npm.depends clause of the package.js.
Instead we check npm versions of installed packages at runtime, on server startup, in development environment.
Dependencies as of v 1.0.0:
'merge': '^2.1.1'
Each of these dependencies should be installed at application level:
meteor npm install <package> --save
Translations
New and updated translations are willingly accepted, and more than welcome. Just be kind enough to submit a PR on the Github repository.
Cookies and comparable technologies
pwix:cookie-manager makes use of localStorage to record its technical and functionals required informations. All of these are considered as non disableable by the user, and are advertised as such.
P. Wieser
- Last updated on 2023, May 1st