Documentation ¶
Overview ¶
Package iabconsent provides structs and methods for parsing Vendor Consent Strings as defined by the IAB Consent String 1.1 Spec. More info on the spec here: https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/Consent%20string%20and%20vendor%20list%20formats%20v1.1%20Final.md#vendor-consent-string-format-.
Copyright (c) 2018 LiveRamp. All rights reserved.
Written by Andy Day, Software Engineer @ LiveRamp for use in the LiveRamp Pixel Server.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Format ¶
func Format(p *ParsedConsent) string
Format takes a ParsedConsent and returns the base64 Raw URL Encoded string
Example Usage:
var cs = iabconsent.Format("BONJ5bvONJ5bvAMAPyFRAL7AAAAMhuqKklS-gAAAAAAAAAAAAAAAAAAAAAAAAAA")
Types ¶
type Bits ¶
type Bits struct {
// contains filtered or unexported fields
}
func (*Bits) WriteNumber ¶
func (*Bits) WriteString ¶
WriteString writes the value v in the len(v)* 6 next bits
type ConsentReader ¶
type ConsentReader struct {
*Bits
}
ConsentReader provides additional Consent String-specific bit-reading functionality on top of Bits.
func NewConsentReader ¶
func NewConsentReader(src []byte) *ConsentReader
NewConsentReader returns a new ConsentReader backed by src.
func (*ConsentReader) ReadBitField ¶
func (r *ConsentReader) ReadBitField(n uint) map[int]bool
ReadBitField reads the next n bits and converts them to a map[int]bool.
func (*ConsentReader) ReadRangeEntries ¶
func (r *ConsentReader) ReadRangeEntries(n uint) []*RangeEntry
ReadRangeEntries reads the next n bits and converts them to a []*RangeEntry
func (*ConsentReader) ReadString ¶
func (r *ConsentReader) ReadString(n uint) string
ReadString returns a string of length n by reading the next 6 * n bits.
func (*ConsentReader) ReadTime ¶
func (r *ConsentReader) ReadTime() time.Time
ReadTime reads the next 36 bits representing the epoch time in deciseconds and converts it to a time.Time.
func (*ConsentReader) WriteTime ¶
func (r *ConsentReader) WriteTime(v time.Time)
WriteTime writes the value v in the next 36 bits
type ParsedConsent ¶
type ParsedConsent struct { Version int Created time.Time LastUpdated time.Time CMPID int CMPVersion int ConsentScreen int ConsentLanguage string VendorListVersion int PurposesAllowed map[int]bool MaxVendorID int IsRangeEncoding bool ConsentedVendors map[int]bool DefaultConsent bool NumEntries int RangeEntries []*RangeEntry }
ParsedConsent represents data extracted from an IAB Consent String, v1.1.
func Parse ¶
func Parse(s string) (p *ParsedConsent, err error)
Parse takes a base64 Raw URL Encoded string which represents a Vendor Consent String and returns a ParsedConsent with its fields populated with the values stored in the string.
Example Usage:
var pc, err = iabconsent.Parse("BONJ5bvONJ5bvAMAPyFRAL7AAAAMhuqKklS-gAAAAAAAAAAAAAAAAAAAAAAAAAA")
func (*ParsedConsent) EveryPurposeAllowed ¶
func (p *ParsedConsent) EveryPurposeAllowed(ps []int) bool
EveryPurposeAllowed returns true iff every purpose number in ps exists in the ParsedConsent, otherwise false.
func (*ParsedConsent) PurposeAllowed ¶
func (p *ParsedConsent) PurposeAllowed(v int) bool
PurposeAllowed returns true if the purpose number exists in the ParsedConsent and is true, otherwise false
func (*ParsedConsent) ToConsentString ¶
func (p *ParsedConsent) ToConsentString() string
func (*ParsedConsent) ToString ¶
func (p *ParsedConsent) ToString() string
func (*ParsedConsent) VendorAllowed ¶
func (p *ParsedConsent) VendorAllowed(v int) bool
VendorAllowed returns true if the ParsedConsent contains affirmative consent for VendorID v.
type RangeEntry ¶
RangeEntry defines an inclusive range of vendor IDs from StartVendorID to EndVendorID.