consent-string
Advanced tools
Comparing version 1.3.2 to 1.4.1
{ | ||
"name": "consent-string", | ||
"version": "1.3.2", | ||
"version": "1.4.1", | ||
"description": "Encode and decode web-safe base64 consent information with the IAB EU's GDPR Transparency and Consent Framework", | ||
"homepage": "https://github.com/InteractiveAdvertisingBureau/Consent-String-SDK-JS", | ||
"repository": "https://github.com/InteractiveAdvertisingBureau/Consent-String-SDK-JSl", | ||
"repository": "https://github.com/InteractiveAdvertisingBureau/Consent-String-SDK-JS", | ||
"keywords": [ | ||
@@ -13,5 +13,2 @@ "consent", | ||
"license": "MIT", | ||
"files": [ | ||
"dist/" | ||
], | ||
"main": "dist/index.js", | ||
@@ -18,0 +15,0 @@ "types": "dist/index.d.ts", |
248
README.md
@@ -27,3 +27,2 @@ # Transparency and Consent Framework: Consent String SDK (JavaScript) | ||
- [Usage](#usage) | ||
- [Use cases](#use-cases) | ||
- [Documentation](#documentation) | ||
@@ -104,250 +103,9 @@ | ||
## Use cases | ||
### Vendors | ||
Vendors that receive a consent string encoded by a Consent Management Platform, on a webpage or in a mobile application, can decode the string and determine if they the user has given consent to their specific purpose and vendor IDs. | ||
**Example:** | ||
Assuming you are the vendor with ID 1 and want to check that the user has given consent to access her device (purpose 1) and personalize advertizing (purpose 2): | ||
```javascript | ||
const { ConsentString } = require('consent-string'); | ||
const consentData = new ConsentString('encoded base64 consent string received'); | ||
if ( | ||
consentData.isVendorAllowed(1) | ||
&& consentData.isPurposeAllowed(1) | ||
&& consentData.isPurposeAllowed(2) | ||
) { | ||
// The vendor ID and the purposes are all allowed | ||
// Process with your data collection / processing | ||
} else { | ||
// Either the vendor or one of the purposes is not allowed by the user | ||
// Do not collect or process personal data | ||
} | ||
``` | ||
### Consent management platforms | ||
CMPs can read a cookie, modify its content then update the cookie value with the correct encoding. | ||
```javascript | ||
const { ConsentString } = require('consent-string'); | ||
// Decode the base64-encoded consent string contained in the cookie | ||
const consentData = new ConsentString(readCookieValue()); | ||
// Modify the consent data | ||
consentData.setCmpId(1); | ||
consentData.setConsentScreen(1); | ||
consentData.setPurposeAllowed(12, true); | ||
// Update the cookie value | ||
writeCookieValue(consentData.getConsentString()); | ||
``` | ||
**Note:** CMPs need to manage the cookie operations (reading and writing) themselves. | ||
## Documentation | ||
#### constructor | ||
Constructs new object | ||
#### Consent String | ||
[Methods](consent_string_methods.md) | ||
```javascript | ||
// @param str is the web-safe base64 encoded consent string or null (no parameter) | ||
constructor( str = null ) | ||
``` | ||
--- | ||
[Use Cases](consent_string_use_cases.md) | ||
#### getConsentString() | ||
Gets the consent string either new one created or one passed in on construction. | ||
```javascript | ||
// @return web-safe base64 encoded consent string | ||
getConsentString() | ||
``` | ||
--- | ||
#### getMaxVendorId() | ||
Gets the maxVendorId from the vendor list. | ||
```javascript | ||
// @return number | ||
getMaxVendorId() | ||
``` | ||
--- | ||
#### getParsedVendorConsents() | ||
Gets the binary string format of the vendor consents. 1 being has consent 0 being no consent. | ||
```javascript | ||
// @return string (binary) | ||
getParsedVendorConsents() | ||
``` | ||
--- | ||
#### getParsedPurposes() | ||
Gets the binary string format of the purpose consents. 1 being has consent 0 being no consent. | ||
```javascript | ||
// @return string (binary) | ||
getParsedPurposes() | ||
``` | ||
--- | ||
#### getMetadataString() | ||
Gets the metadata string as defined in the response to the getVendorConsents method (ie binary string that includes only header information like consent string version, timestamps, cmp ID, etc. but no purposes/consents information). | ||
```javascript | ||
// @return web-safe base64 encoded metadata string | ||
getMetadataString() | ||
``` | ||
--- | ||
#### ConsentString.decodeMetadataString() (Static Method) | ||
Decodes the metadata string. | ||
```javascript | ||
// @return object with metadata fields | ||
ConsentString.decodeMetadataString(encodedMetadataString) | ||
``` | ||
--- | ||
#### getVersion() | ||
The version number in which this consent string specification adheres to | ||
```javascript | ||
// @return integer version number of consent string specification | ||
getVersion() | ||
``` | ||
--- | ||
#### getVendorListVersion() | ||
Returns either the vendor list version set by `setGlobalVendorList` or whatever was previously set as the consent string when the object was created | ||
```javascript | ||
// @return integer version number of vendor list version | ||
getVendorListVersion() | ||
``` | ||
--- | ||
#### setGlobalVendorList( gvlObject ) | ||
Sets the global vendor list object. Generally this would be the parsed JSON that comes from the IAB hosted Global Vendor List. | ||
```javascript | ||
// @param gvlObject is the parsed JSON that conforms to the IAB EU TCF Vendor List Specification | ||
setGlobalVendorList( gvlObject ) | ||
``` | ||
--- | ||
#### setCmpId( cmpId ) | ||
Sets CMP ID number that is assigned to your CMP from the IAB EU. A unique ID will be assigned to each Consent Manager Provider | ||
```javascript | ||
// @param cmpId the id for the cmp setting the consent string values. | ||
setCmpId( cmpId ) | ||
``` | ||
--- | ||
#### getCmpId() | ||
Get the ID of the CMP from the consent string | ||
```javascript | ||
// @return CMP id | ||
getCmpId() | ||
``` | ||
--- | ||
#### setCmpVersion( version ) | ||
Sets the version of the CMP code that created or updated the consent string | ||
```javascript | ||
// @param version - CMP version | ||
setCmpVersion( version ) | ||
``` | ||
--- | ||
#### getCmpVersion() | ||
The version of the CMP code that created or updated the consent string | ||
```javascript | ||
// @return version CMP version | ||
getCmpVersion() | ||
``` | ||
--- | ||
#### setConsentScreen( screenId ) | ||
Sets the consent screen id. The screen number is CMP and CMP Version specific, and is for logging proof of consent | ||
```javascript | ||
// @param screenId id for the screen in which the consent values were confirmed | ||
setConsentScreen( screenId ) | ||
``` | ||
--- | ||
#### getConsentScreen() | ||
The screen number is CMP and CmpVersion specific, and is for logging proof of consent | ||
```javascript | ||
// @return screenId id for the screen in which the consent values were confirmed | ||
getConsentScreen() | ||
``` | ||
--- | ||
#### setConsentLanguage( language ) | ||
Sets consent language. Two-letter ISO639-1 language code that CMP asked for consent in | ||
```javascript | ||
// @param language two character ISO639-1 language code | ||
setConsentLanguage( language ) | ||
``` | ||
--- | ||
#### getConsentLanguage() | ||
gets consent language. Two-letter ISO639-1 language code that CMP asked for consent in | ||
```javascript | ||
// @return language two character ISO639-1 language code | ||
getConsentLanguage() | ||
``` | ||
--- | ||
#### setPurposesAllowed( purposeIdArray) | ||
Sets the allowed purposes as an array of purpose ids | ||
```javascript | ||
// @param purposeIdArray variable length array of integers setting which purposes are allowed. If the id is in the array it’s allowed. | ||
setPurposesAllowed( purposeIdArray) | ||
``` | ||
--- | ||
#### getPurposesAllowed() | ||
Gets an array of purposes allowed either set by `setPurposesAllowed` or whatever was previously set by the initializing consent string | ||
```javascript | ||
// @return variable length array of integers setting which purposes are allowed. If the id is in the array it’s allowed. | ||
getPurposesAllowed() | ||
``` | ||
--- | ||
#### setPurposeAllowed( purposeId, value ) | ||
Sets a single purpose by id and boolean value | ||
```javascript | ||
// @param purposeId the purpose id | ||
// @param value the boolean value to set it to true for allowed false for not allowed | ||
setPurposeAllowed( purposeId, value ) | ||
``` | ||
--- | ||
#### isPurposeAllowed( purposeId ) | ||
Gets a single purpose by id and returns boolean value | ||
```javascript | ||
// @param purposeId the purpose id | ||
// @return boolean value true for allowed false for not allowed | ||
isPurposeAllowed( purposeId ) | ||
``` | ||
--- | ||
#### setVendorAllowed( vendorId, valueBool ) | ||
Sets consent value for a vendor id | ||
```javascript | ||
// @param vendorId - vendor id to set consent value for | ||
// @param value - the boolean value to set the consent to | ||
setVendorAllowed( vendorId, valueBool ) | ||
``` | ||
--- | ||
#### isVendorAllowed( vendorId ) | ||
For determining if the vendor consent value bit is turned on or off for a particular vendor id. | ||
```javascript | ||
// @param vendorId vendor id to see if consent is allowed for | ||
// @return boolean value of consent for that vendor id | ||
isVendorAllowed( vendorId ) | ||
``` | ||
## About | ||
@@ -354,0 +112,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
100217
24
2700
127
1