From 2793c7682132b90b2fe1b5f09c9bc6a50a7552e7 Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Tue, 18 Jun 2024 09:02:05 -0700 Subject: [PATCH] consentManagementTcf: add flag to set dsarequired --- modules/consentManagementTcf.js | 5 +++++ test/spec/fpd/gdpr_spec.js | 26 ++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/modules/consentManagementTcf.js b/modules/consentManagementTcf.js index c7c618635ba..d1b27d64c50 100644 --- a/modules/consentManagementTcf.js +++ b/modules/consentManagementTcf.js @@ -22,6 +22,7 @@ export let userCMP; export let consentTimeout; export let gdprScope; export let staticConsentData; +let dsaPlatform = false; let actionTimeout; let consentData; @@ -282,6 +283,7 @@ export function setConsentConfig(config) { // if true, then gdprApplies should be set to true gdprScope = config.defaultGdprScope === true; + dsaPlatform = !!config.dsaPlatform; logInfo('consentManagement module has been activated...'); @@ -315,6 +317,9 @@ export function enrichFPDHook(next, fpd) { } deepSetValue(ortb2, 'user.ext.consent', consent.consentString); } + if (dsaPlatform) { + deepSetValue(ortb2, 'regs.ext.dsa.dsarequired', 3); + } return ortb2; })); } diff --git a/test/spec/fpd/gdpr_spec.js b/test/spec/fpd/gdpr_spec.js index 68303657939..acd3531c2a2 100644 --- a/test/spec/fpd/gdpr_spec.js +++ b/test/spec/fpd/gdpr_spec.js @@ -1,5 +1,7 @@ import {gdprDataHandler} from '../../../src/adapterManager.js'; import {enrichFPDHook} from '../../../modules/consentManagementTcf.js'; +import {config} from 'src/config.js'; +import 'src/prebid.js'; describe('GDPR FPD enrichment', () => { let sandbox, consent; @@ -12,9 +14,9 @@ describe('GDPR FPD enrichment', () => { sandbox.restore(); }) - function callHook() { + function callHook(ortb2 = {}) { let result; - enrichFPDHook((res) => { result = res }, Promise.resolve({})); + enrichFPDHook((res) => { result = res }, Promise.resolve(ortb2)); return result; } @@ -44,4 +46,24 @@ describe('GDPR FPD enrichment', () => { }) }) }); + + describe('dsa', () => { + describe('when dsaPlaform is set', () => { + beforeEach(() => { + config.setConfig({ + consentManagement: { + gdpr: { + dsaPlatform: true + } + } + }); + }); + + it('sets dsarequired', () => { + return callHook().then(ortb2 => { + expect(ortb2.regs.ext.dsa.dsarequired).to.equal(3); + }); + }); + }); + }); });