Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adagio Bid Adapter: update video params validation #9542

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions modules/adagioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
isFn,
isInteger,
isNumber,
isArrayOfNums,
logError,
logInfo,
logWarn,
Expand Down Expand Up @@ -48,33 +49,32 @@ const ADAGIO_PUBKEY = 'AL16XT44Sfp+8SHVF1UdC7hydPSMVLMhsYknKDdwqq+0ToDSJrP0+Qh0k
const ADAGIO_PUBKEY_E = 65537;
const CURRENCY = 'USD';

// This provide a whitelist and a basic validation
// of OpenRTB 2.5 options used by the Adagio SSP.
// https://www.iab.com/wp-content/uploads/2016/03/OpenRTB-API-Specification-Version-2-5-FINAL.pdf
// This provide a whitelist and a basic validation of OpenRTB 2.6 options used by the Adagio SSP.
// https://iabtechlab.com/wp-content/uploads/2022/04/OpenRTB-2-6_FINAL.pdf
export const ORTB_VIDEO_PARAMS = {
'mimes': (value) => Array.isArray(value) && value.length > 0 && value.every(v => typeof v === 'string'),
'minduration': (value) => isInteger(value),
'maxduration': (value) => isInteger(value),
'protocols': (value) => Array.isArray(value) && value.every(v => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].indexOf(v) !== -1),
'protocols': (value) => isArrayOfNums(value),
'w': (value) => isInteger(value),
'h': (value) => isInteger(value),
'startdelay': (value) => isInteger(value),
'placement': (value) => [1, 2, 3, 4, 5].indexOf(value) !== -1,
'linearity': (value) => [1, 2].indexOf(value) !== -1,
'skip': (value) => [0, 1].indexOf(value) !== -1,
'placement': (value) => isInteger(value),
'linearity': (value) => isInteger(value),
'skip': (value) => isInteger(value),
'skipmin': (value) => isInteger(value),
'skipafter': (value) => isInteger(value),
'sequence': (value) => isInteger(value),
'battr': (value) => Array.isArray(value) && value.every(v => Array.from({length: 17}, (_, i) => i + 1).indexOf(v) !== -1),
'battr': (value) => isArrayOfNums(value),
'maxextended': (value) => isInteger(value),
'minbitrate': (value) => isInteger(value),
'maxbitrate': (value) => isInteger(value),
'boxingallowed': (value) => [0, 1].indexOf(value) !== -1,
'playbackmethod': (value) => Array.isArray(value) && value.every(v => [1, 2, 3, 4, 5, 6].indexOf(v) !== -1),
'playbackend': (value) => [1, 2, 3].indexOf(value) !== -1,
'delivery': (value) => [1, 2, 3].indexOf(value) !== -1,
'pos': (value) => [0, 1, 2, 3, 4, 5, 6, 7].indexOf(value) !== -1,
'api': (value) => Array.isArray(value) && value.every(v => [1, 2, 3, 4, 5, 6].indexOf(v) !== -1)
'boxingallowed': (value) => isInteger(value),
'playbackmethod': (value) => isArrayOfNums(value),
'playbackend': (value) => isInteger(value),
'delivery': (value) => isInteger(value),
'pos': (value) => isInteger(value),
'api': (value) => isArrayOfNums(value)
};

let currentWindow;
Expand Down
4 changes: 3 additions & 1 deletion modules/adagioBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ var adUnits = [
cpm: 3.00 // default to 1.00
},
video: {
api: [2, 7], // Required - Your video player must at least support the value 2 and/or 7.
playbackMethod: [6], // Highly recommended
skip: 0
// OpenRTB 2.5 video options defined here override ones defined in mediaTypes.
// OpenRTB video options defined here override ones defined in mediaTypes.
},
native: {
// Optional OpenRTB Native 1.2 request object. Only `context`, `plcmttype` fields are supported.
Expand Down
4 changes: 2 additions & 2 deletions test/spec/modules/adagioBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ describe('Adagio bid adapter', () => {
context: 'outstream',
playerSize: [[300, 250]],
mimes: ['video/mp4'],
api: 5, // will be removed because invalid
playbackmethod: [7], // will be removed because invalid
api: 'val', // will be removed because invalid
playbackmethod: ['val'], // will be removed because invalid
}
},
}).withParams({
Expand Down