forked from LiveRamp/iabconsent
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
891f6be
commit ef7d015
Showing
7 changed files
with
805 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package iabconsent | ||
|
||
import "github.com/pkg/errors" | ||
|
||
const ( | ||
CCPAYes = 'Y' | ||
CCPANo = 'N' | ||
CCPANotApplicable = '-' | ||
CCPAVersion = 1 | ||
) | ||
|
||
// CcpaParsedConsent represents data extract from a California Consumer Privacy Act (CCPA) consent string. | ||
// Format can be found here: https://github.com/InteractiveAdvertisingBureau/USPrivacy/blob/master/CCPA/US%20Privacy%20String.md | ||
type CcpaParsedConsent struct { | ||
// The version of this string specification used to encode the string | ||
Version int | ||
|
||
// N = No, Y = Yes, - = Not Applicable | ||
Notice uint8 | ||
|
||
// N = No, Y = Yes, - = Not Applicable; For use ONLY when CCPA does not apply. | ||
OptOutSale uint8 | ||
|
||
// 0 = No, 1 = Yes, - = Not Applicable | ||
LSPACoveredTransaction uint8 | ||
} | ||
|
||
func IsValidCCPAString(ccpaString string) (bool, error) { | ||
if len(ccpaString) != 4 { | ||
return false, errors.Wrap(nil, "invalid uspv consent string length") | ||
} | ||
|
||
if ccpaString[0]-'0' != CCPAVersion { | ||
return false, errors.Wrap(nil, "invalid uspv consent string version") | ||
} | ||
|
||
for i := 1; i < 4; i++ { | ||
if ccpaString[i] != CCPAYes && ccpaString[i] != CCPANo && ccpaString[i] != CCPANotApplicable { | ||
return false, errors.Wrap(nil, "invalid uspv consent string") | ||
} | ||
} | ||
|
||
return true, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.