CWT
A consent web token represents the GDPR consents expressed by a user. It can be used for storage or to be shared with third-parties.
Example:
const token = new CWT({
issuer: 'issuer',
user_id: 'user@domain.com',
user_id_type: 'email'
});
Constructor Summary
| Public Constructor | ||
| public |
constructor(tokenContent: Object) Create a new Consent web token |
|
Member Summary
| Public Members | ||
| public |
A list of consents already given by the user |
|
| public |
A unique ID identifying the issuer of the token |
|
| public |
The ID of the user that owns the token |
|
| public |
If the user ID is hashed, this is the method used for generating the hash (md5, sha1, sha256) |
|
| public |
The type of ID (email, uuid, adid, etc.) |
|
| public |
The CWT specification version |
|
Method Summary
| Public Methods | ||
| public |
getConsentStatus(purpose: string, vendorId: string): boolean Get the consent status of the user for a specific purpose/vendor |
|
| public |
setConsentStatus(status: string, purpose: string, vendorId: string) Set the consent status for the user |
|
| public |
Generate a base64-encoded version of the token It first encode the token as JSON then base64-encode it. |
|
| public |
Generate a JSON-encoded version of the token |
|
| public |
Export the token information as a plain JavaScript object |
|
Public Constructors
public constructor(tokenContent: Object) source
Create a new Consent web token
Params:
| Name | Type | Attribute | Description |
| tokenContent | Object | The content of the token |
|
| tokenContent.issuer | string | A unique ID identifying the issuer of the token |
|
| tokenContent.user_id | string |
|
The ID of the user that owns the token |
| tokenContent.user_id_type | string |
|
The type of ID (email, uuid, adid, etc.) |
| tokenContent.user_id_hash_method | string |
|
If the user ID is hashed, this is the method used for generating the hash (md5, sha1, sha256) |
| tokenContent.consents | Object[] |
|
A list of consents already given by the user |
Public Members
Public Methods
public getConsentStatus(purpose: string, vendorId: string): boolean source
Get the consent status of the user for a specific purpose/vendor
Returns true if consent has been given, false if consent has been denied and undefined if no consent information is available
Example:
const token = new CWT('issuer');
token.setConsentStatus(CWT.Purposes.Cookies, 'didomi');
token.getConsentStatus(CWT.Purposes.Cookies, 'didomi');
public setConsentStatus(status: string, purpose: string, vendorId: string) source
Set the consent status for the user
Params:
| Name | Type | Attribute | Description |
| status | string | The consent status (yes/no) of the user for the vendor |
|
| purpose | string | The purpose for which the user has given consent |
|
| vendorId | string | The unique vendor ID for which the user has given consent. Use |
Example:
const token = new CWT('issuer');
token.setConsentStatus(
true,
CWT.Purposes.Cookies,
'didomi'
);
