Documentation ¶
Index ¶
- func DecodeConsent(consent string) ([]byte, error)
- func GetVersion(r *iabconsent.ConsentReader) iabconsent.TCFVersion
- func ParseV1(r *iabconsent.ConsentReader) (*iabconsent.ParsedConsent, error)
- func ParseV2(r *iabconsent.ConsentReader) (*iabconsent.V2ParsedConsent, error)
- type Consent
- type ConsentV1
- func (c *ConsentV1) CMPID() int
- func (c *ConsentV1) GetConsentBitstring() string
- func (c *ConsentV1) GetConsentPurposeBitstring() string
- func (c *ConsentV1) GetInterestsBitstring() string
- func (c *ConsentV1) GetPublisherRestrictions() []*iabconsent.PubRestrictionEntry
- func (c *ConsentV1) HasConsentedLegitimateInterestForPurpose(purposeID int) bool
- func (c *ConsentV1) HasConsentedPurpose(purposeID int) bool
- func (c *ConsentV1) HasUserConsented(vendorID int) bool
- func (c *ConsentV1) HasUserLegitimateInterest(vendorID int) bool
- func (c *ConsentV1) IsCMPValid() bool
- func (c *ConsentV1) Version() int
- type ConsentV2
- func (c *ConsentV2) CMPID() int
- func (c *ConsentV2) GetConsentBitstring() string
- func (c *ConsentV2) GetConsentPurposeBitstring() string
- func (c *ConsentV2) GetInterestsBitstring() string
- func (c *ConsentV2) GetPublisherRestrictions() []*iabconsent.PubRestrictionEntry
- func (c *ConsentV2) HasConsentedLegitimateInterestForPurpose(purposeID int) bool
- func (c *ConsentV2) HasConsentedPurpose(purposeID int) bool
- func (c *ConsentV2) HasUserConsented(vendorID int) bool
- func (c *ConsentV2) HasUserLegitimateInterest(vendorID int) bool
- func (c *ConsentV2) IsCMPValid() bool
- func (c *ConsentV2) Version() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeConsent ¶
DecodeConsent receives a GDPR IAB consent string and decodes the CORE segment only, returning it. It also returns an error if something happened and we couldn't decode it.
func GetVersion ¶
func GetVersion(r *iabconsent.ConsentReader) iabconsent.TCFVersion
GetVersion extracts the version from the consent string, moving the data pointer so we don't have to reparse it.
func ParseV1 ¶
func ParseV1(r *iabconsent.ConsentReader) (*iabconsent.ParsedConsent, error)
ParseV1 uses a consent reader to extract information from a TCF 1.0 version consent string.
func ParseV2 ¶
func ParseV2(r *iabconsent.ConsentReader) (*iabconsent.V2ParsedConsent, error)
ParseV2 uses a consent reader to extract information from a TCF 2.0 version consent string.
Types ¶
type Consent ¶
type Consent interface { // Version returns the version of this consent string. Version() int // CMPID returns the CMP ID of this consent string. CMPID() int // HasConsentedPurpose returns the consent value for a Purpose established on the legal basis of consent. // The Purposes are numerically identified and published in the Global Vendor List. HasConsentedPurpose(purposeID int) bool // GetConsentPurposeBitstring returns a string of 1 & 0 each of them representing the consent // given for a specific purposeID. // The first number is for the purposeID 1, the second number for the purposeID 2, // and so on. GetConsentPurposeBitstring() string // HasConsentedLegitimateInterestForPurpose returns the Purpose’s transparency requirements // are met for each Purpose on the legal basis of legitimate interest and the user has not // exercised their “Right to Object” to that Purpose. HasConsentedLegitimateInterestForPurpose(purposeID int) bool // HasUserConsented returns true if the user has given consent to the vendorID passed // as parameter. HasUserConsented(vendorID int) bool // HasUserLegitimateInterest returns true if the CMP has established transparency for a vendor's // legitimate interest disclosures. If a user exercises their “Right To Object” to a vendor’s // processing based on a legitimate interest, then it returns false. HasUserLegitimateInterest(vendorID int) bool // GetConsentBitstring returns a string of 1 & 0 each of them representing the consent // given for a specific vendorID. // The first number is for the vendorID 1, the second number for the vendorID 2, // and so on. GetConsentBitstring() string // GetInterestsBitstring returns a string of 1 & 0 each of them representing the // return of `HasUserLegitimateInterest` method for the vendorID in that position of the string. // The first number is for the vendorID 1, the second number for the vendorID 2, // and so on. GetInterestsBitstring() string // GetPublisherRestrictions returns a list of restrictions per publisher, if it relates. GetPublisherRestrictions() []*iabconsent.PubRestrictionEntry // IsCMPListLoaded returns if the list of valid CMPs was properly loaded or not. IsCMPListLoaded() bool // IsCMPValid validates the consent string CMP ID agains the list of valid ones downloaded from IAB. IsCMPValid() bool }
Consent is an interface to retrieve the most important information from consent strings, no matter if they are v1 or v2.
func NewConsent ¶
NewConsent returns a Consent instance with all the necessary information available. It returns an error if something went wrong.
func NewConsentV1 ¶
func NewConsentV1(reader *iabconsent.ConsentReader) (Consent, error)
NewConsentV1 returns a consent interface from the reader received, with an error if something went wrong.
func NewConsentV2 ¶
func NewConsentV2(reader *iabconsent.ConsentReader) (Consent, error)
NewConsentV2 returns a consent interface from the reader received, with an error if something went wrong.
type ConsentV1 ¶
type ConsentV1 struct { *cmp.Consent ParsedConsent *iabconsent.ParsedConsent }
ConsentV1 is an implementation of the Consent interface used to retrieve consent information given a TCF 1.0 format.
func (*ConsentV1) GetConsentBitstring ¶
GetConsentBitstring returns a string of 1 & 0 each of them representing the consent given for a specific vendorID (the first number is for the vendorID 1, and so on).
func (*ConsentV1) GetConsentPurposeBitstring ¶
GetConsentPurposeBitstring returns a string of 1 & 0 each of them representing the consent given for a specific purposeID.
func (*ConsentV1) GetInterestsBitstring ¶
GetInterestsBitstring returns an empty string always because consent TFC 1.0 doesn't implement user legitimate interests.
func (*ConsentV1) GetPublisherRestrictions ¶
func (c *ConsentV1) GetPublisherRestrictions() []*iabconsent.PubRestrictionEntry
GetPublisherRestrictions returns an empty list because consent TFC 1.0 doesn't implement user legitimate interests.
func (*ConsentV1) HasConsentedLegitimateInterestForPurpose ¶
HasConsentedLegitimateInterestForPurpose returns always true because consent TFC 1.0 doesn't come with this information.
func (*ConsentV1) HasConsentedPurpose ¶
HasConsentedPurpose returns always true because consent TFC 1.0 doesn't come with this information.
func (*ConsentV1) HasUserConsented ¶
HasUserConsented returns true if the user has given consent to the vendorID passed as parameter.
func (*ConsentV1) HasUserLegitimateInterest ¶
HasUserLegitimateInterest returns always true because consent TFC 1.0 doesn't come with this information.
func (*ConsentV1) IsCMPValid ¶ added in v0.3.0
IsCMPValid validates the consent string CMP ID agains the list of valid ones downloaded from IAB.
type ConsentV2 ¶
type ConsentV2 struct { cmp.Consent ParsedConsent *iabconsent.V2ParsedConsent }
ConsentV2 is an implementation of the Consent interface used to retrieve consent information given a TCF 1.0 format.
func (*ConsentV2) GetConsentBitstring ¶
GetConsentBitstring returns a string of 1 & 0 each of them representing the consent given for a specific vendorID (the first number is for the vendorID 1, and so on).
func (*ConsentV2) GetConsentPurposeBitstring ¶
GetConsentPurposeBitstring returns a string of 1 & 0 each of them representing the consent given for a specific purposeID.
func (*ConsentV2) GetInterestsBitstring ¶
GetInterestsBitstring returns a string of 1 & 0 each of them representing the user's interest to `Right To Object` for a specific vendorID (the first number is for the vendorID 1, and so on).
func (*ConsentV2) GetPublisherRestrictions ¶
func (c *ConsentV2) GetPublisherRestrictions() []*iabconsent.PubRestrictionEntry
GetPublisherRestrictions returns a list of restrictions per publisher, if it relates.
func (*ConsentV2) HasConsentedLegitimateInterestForPurpose ¶
HasConsentedLegitimateInterestForPurpose returns the Purpose’s transparency requirements are met for each Purpose on the legal basis of legitimate interest and the user has not exercised their “Right to Object” to that Purpose.
func (*ConsentV2) HasConsentedPurpose ¶
HasConsentedPurpose returns the consent value for a Purpose established on the legal basis of consent. The Purposes are numerically identified and published in the Global Vendor List.
func (*ConsentV2) HasUserConsented ¶
HasUserConsented returns true if the user has given consent to the vendorID passed as parameter.
func (*ConsentV2) HasUserLegitimateInterest ¶
HasUserLegitimateInterest returns true if the CMP has established transparency for a vendor's legitimate interest disclosures. If a user exercises their “Right To Object” to a vendor’s processing based on a legitimate interest, then it returns false.
func (*ConsentV2) IsCMPValid ¶ added in v0.3.0
IsCMPValid validates the consent string CMP ID agains the list of valid ones downloaded from IAB.