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 ¶
- type ConsentReader
- func (r *ConsentReader) ReadBitField(n uint) (map[int]bool, error)
- func (r *ConsentReader) ReadInt(n uint) (int, error)
- func (r *ConsentReader) ReadRangeEntries(n uint) ([]*RangeEntry, error)
- func (r *ConsentReader) ReadString(n uint) (string, error)
- func (r *ConsentReader) ReadTime() (time.Time, error)
- type ParsedConsent
- type RangeEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConsentReader ¶ added in v0.2.0
type ConsentReader struct {
*bits.Reader
}
ConsentReader provides additional Consent String-specific bit-reading functionality on top of bits.Reader.
func NewConsentReader ¶ added in v0.2.0
func NewConsentReader(src []byte) *ConsentReader
NewConsentReader returns a new ConsentReader backed by src.
func (*ConsentReader) ReadBitField ¶ added in v0.2.0
func (r *ConsentReader) ReadBitField(n uint) (map[int]bool, error)
ReadBitField reads the next n bits and converts them to a map[int]bool.
func (*ConsentReader) ReadInt ¶ added in v0.2.0
func (r *ConsentReader) ReadInt(n uint) (int, error)
ReadInt reads the next n bits and converts them to an int.
func (*ConsentReader) ReadRangeEntries ¶ added in v0.2.0
func (r *ConsentReader) ReadRangeEntries(n uint) ([]*RangeEntry, error)
func (*ConsentReader) ReadString ¶ added in v0.2.0
func (r *ConsentReader) ReadString(n uint) (string, error)
ReadString returns a string of length n by reading the next 6 * n 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) (*ParsedConsent, 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 ¶ added in v0.2.0
func (p *ParsedConsent) EveryPurposeAllowed(ps []int) bool
EveryPurposeAllowed returns true iff every purpose number in ps exists in the ParsedConsent, otherwise false.
func (*ParsedConsent) VendorAllowed ¶
func (p *ParsedConsent) VendorAllowed(v int) bool
VendorAllowed returns true if the ParsedConsent contains affirmative consent for VendorID v.
type RangeEntry ¶ added in v0.2.0
RangeEntry defines an inclusive range of vendor IDs from StartVendorID to EndVendorID.