termsinator
Plugin to simplify consent management.
Requirements
This plugin is based on the following stack:
Installation
npm install --save termsinator
Usage
const Termsinator = /* This is the most simplest configuration, check out the docs for more features */Termsinator
Config
You can configurate Termsinator
anytime by calling:
Termsinator
The following props are available for configuration:
server
Sets all necessary endpoints. It should look like this:
Termsinator
database
Sets schema methods and hooks.
It should look like this:
Termsinator
IMPORTANT: If setConsentOnCreate === true
, and the id
on the document
is a function, the request
parameter is not supported and will be undefined
Termsinator
will expose the following methods on all of your user documents:
userDocument.getConsent(req)
-> return the current consent status and all historical consents
current: date: '...' // Date of consent action - null if no consent given status: '...' //Enum: ['accepted', 'declined', 'undetermined'] document: '...' //Path to terms document metadata: id: '...' // Document ID date: '...' // Document date message: '...' // Document message (Changelog) history: CONSENT // Array of historical consents (same as "current")
userDocument.setConsent()
-> return the current consent status and all historical consents
userDocument
ui
Set ui spesific properties like i18n, logo etc.
Example:
ui: logo: 'https://myapp.com/logo' title: 'Avtalevilkår' termsLink: 'Les gjennom avtalevilkårene' termsCheckbox: 'Jeg godtar avtalevilkårene' submitButton: 'Send og godkjenn'
It is also possible to set ui with a function that has the request as first parameter. This allows for more dynamic content.
Example:
{ // Do something like language resolving etc return logo: 'https://myapp.com/logo' title: 'Avtalevilkår' termsLink: 'Les gjennom avtalevilkårene' termsCheckbox: 'Jeg godtar avtalevilkårene' submitButton: 'Send og godkjenn' }
documents
Manage your terms & conditions, add new terms etc.
// Document object id: String document: String date: String // optional external: Boolean message: String
If external === true
, the document
property will be treated as a URL, not a path on disk
All values on the document
object can be replaced by a function that returns the expected value type. The function will recieve the express request
object as parameter
Example:
; id: '1.0.0' document: '/terms/Terms-1-0-0.pdf' // Relative path (from project root) to file on disk date: '2018-11-01T14:29:24.811Z' { return reqclienttermid // This has to be a string } document: '/path/to/external/api' external: true message: 'Changes in usage of user properties' date: '2018-11-01T15:29:24.811Z'
License
The MIT License Copyright (c) Carsten Jacobsen