Skip to content

Commit

Permalink
Adagio Bid Adapter: update video params validation
Browse files Browse the repository at this point in the history
  • Loading branch information
G15N committed Feb 14, 2023
1 parent 5a3bb63 commit f280f45
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
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) => Array.isArray(value) && value.every(v => [1, 2, 3, 4, 5].indexOf(v) !== -1),
'linearity': (value) => [1, 2].indexOf(value) !== -1,
'skip': (value) => [0, 1].indexOf(value) !== -1,
'placement': (value) => isArrayOfNums(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: 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

0 comments on commit f280f45

Please sign in to comment.