Skip to content

Commit

Permalink
Stop checking for LI
Browse files Browse the repository at this point in the history
  • Loading branch information
zapo committed Dec 17, 2024
1 parent f8c9edb commit dcdabbe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 39 deletions.
35 changes: 3 additions & 32 deletions lib/core/regs/consent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,31 +90,23 @@ describe("getConsent", () => {

// Simulate event where no consent is granted
signal({
publisher: { consents: {}, legitimateInterests: {} },
publisher: { consents: {} },
tcString: "noconsent",
});
expect(consent.deviceAccess).toBe(false);
expect(consent.tcf).toBe("noconsent");

// Simulate event where purpose 1 consent is granted to the publisher
signal({
publisher: { consents: { 1: true }, legitimateInterests: {} },
publisher: { consents: { 1: true } },
tcString: "purpose1",
});
expect(consent.deviceAccess).toBe(true);
expect(consent.tcf).toBe("purpose1");

// Simulate event where purpose 1 consent is legitimate interest to the publisher
signal({
publisher: { consents: {}, legitimateInterests: { 1: true } },
tcString: "purpose1li",
});
expect(consent.deviceAccess).toBe(true);
expect(consent.tcf).toBe("purpose1li");

// Simulate removing consent
signal({
publisher: { consents: {}, legitimateInterests: {} },
publisher: { consents: {} },
tcString: "revoked",
});
expect(consent.deviceAccess).toBe(false);
Expand Down Expand Up @@ -170,7 +162,6 @@ describe("getConsent", () => {
{
SegmentType: 3,
PubPurposesConsent: [],
PubPurposesLITransparency: [],
},
],
},
Expand All @@ -187,7 +178,6 @@ describe("getConsent", () => {
{
SegmentType: 3,
PubPurposesConsent: [1],
PubPurposesLITransparency: [],
},
],
},
Expand All @@ -197,24 +187,6 @@ describe("getConsent", () => {
expect(consent.deviceAccess).toBe(true);
expect(consent.gpp).toBe("purpose1");

// Section tcfeuv2 applies and purpose 1 granted as legitimate interest
// to publisher
signal({
parsedSections: {
[TCFEuV2APIPrefix]: [
{
SegmentType: 3,
PubPurposesConsent: [],
PubPurposesLITransparency: [1],
},
],
},
applicableSections: [TCFEuV2SectionID],
gppString: "purpose1li",
});
expect(consent.deviceAccess).toBe(true);
expect(consent.gpp).toBe("purpose1li");

// Section tcfeuv2 applies and purpose 1 revoked
// to publisher
signal({
Expand All @@ -223,7 +195,6 @@ describe("getConsent", () => {
{
SegmentType: 3,
PubPurposesConsent: [],
PubPurposesLITransparency: [],
},
],
},
Expand Down
12 changes: 5 additions & 7 deletions lib/core/regs/consent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ type Consent = {
gpp?: string;
};

function gdprConsent(): Consent {
function gdprConsent(vendorID?: string): Consent {
const consent: Consent = { deviceAccess: false, reg: "gdpr" };

// For use TCF if available, otherwise use GPP,
// if none available assume device access is not allowed
if (hasTCF()) {
onTCFChange((data) => {
consent.deviceAccess = tcfDeviceAccess(data);
consent.deviceAccess = tcfDeviceAccess(data, vendorID);

Check failure on line 21 in lib/core/regs/consent.ts

View workflow job for this annotation

GitHub Actions / build / build-lib

Expected 1 arguments, but got 2.

Check failure on line 21 in lib/core/regs/consent.ts

View workflow job for this annotation

GitHub Actions / build / build-web

Expected 1 arguments, but got 2.
consent.tcf = data.tcString;
});
} else if (hasGPP()) {
onGPPSectionChange(TCFEuV2SectionID, (data) => {
consent.deviceAccess = gppEUDeviceAccess(data);
consent.deviceAccess = gppEUDeviceAccess(data, vendorID);

Check failure on line 26 in lib/core/regs/consent.ts

View workflow job for this annotation

GitHub Actions / build / build-lib

Expected 1 arguments, but got 2.

Check failure on line 26 in lib/core/regs/consent.ts

View workflow job for this annotation

GitHub Actions / build / build-web

Expected 1 arguments, but got 2.
consent.gpp = data.gppString;
});
}
Expand Down Expand Up @@ -72,16 +72,14 @@ function gppEUDeviceAccess(data: GPPConsentData): boolean {
return false;
}

return (
publisherSubsection.PubPurposesConsent.includes(1) || publisherSubsection.PubPurposesLITransparency.includes(1)
);
return publisherSubsection.PubPurposesConsent.includes(1);
}

function tcfDeviceAccess(data: TCFConsentData): boolean {
if (!data.gdprApplies) {
return true;
}
return !!data.publisher.consents["1"] || !!data.publisher.legitimateInterests["1"];
return !!data.publisher.consents["1"];
}

function onGPPSectionChange(sectionID: number, cb: (_: GPPConsentData) => void): void {
Expand Down

0 comments on commit dcdabbe

Please sign in to comment.