Coder Social home page Coder Social logo

iab-tcf's Introduction

iab-tcf CircleCI

Go code to parse IAB v1/v2 consent based on github.com/LiveRamp/iabconsent library.

This package is just a wrapper on their amazing work to fill our needs.

Usage

Install

go get github.com/hybridtheory/iab-tcf

Example

package main

import (
    "fmt"
    iab "github.com/hybridtheory/iab-tcf"
)

func main() {
    encoded := "COyt4MbOyt4MbMOAAAENAiCgAIAAAAAAAAAAADEAAgIAAAAAAAA.YAAAAAAAAAA"
    consent, err := iab.NewConsent(encoded)
}

CMP vendor list

In order to validate if the CMP received belongs to a valid id there's a loader integrated with the library.

package main

import (
    "fmt"
    iab "github.com/hybridtheory/iab-tcf"
    cmp "github.com/hybridtheory/iab-tcf/cmp"
)

func main() {
    cmp.NewLoader().LoadIDs()
    consent, err := iab.NewConsent(encoded)
    consent.IsCMPValid() // This will return true/false depending on the ids loaded.
}

If instead of the default vendor list https://cmplist.consensu.org/v2/cmp-list.json we want to use our own, we can use an option:

err := cmp.NewLoader(cmp.WithURL("https://example.com/cmp-list.json")).LoadIDs()

The format of the JSON must be the same.

If we want to use our own list of valid CMPs we can simply set the variable:

cmp.ValidCMPs = []int{1, 123}

Testing

We use Ginkgo and Gomega for testing purposes.

ginkgo ./...

iab-tcf's People

Contributors

gguridi avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

odannyc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.